In what instances does Entity Framework automatically load child rows and other related rows as you use them? It seems like sometimes this is done automatically on property accessor, and sometimes you must do it explicitly.
For example, if I have a table called Car, and a table called Wheel, and there are 4 wheels rows for each car row, will EF automatically load the Wheel rows when I access myCar.Wheel, or is the general practice to call myCar.Wheel.Load() first?
In EF 4, lazy loading is done by default if you use code generation or proxies. “Pure” POCOs (not to be confused with so-called POCO proxies) can’t do lazy loading unless you code for it. More details are in this post.
In EF 1, there is no lazy loading, so you must use explicit loading, eager loading, or projection.
Explicit loading means calling
Load(). You generally testIsLoadedbefore callingLoad().Eager loading causes the property to be loaded along with the entity itself. This avoids a second DB query.
Projection causes the EF to generate SQL for only the properties you need, in an optimized way.
Although lazy loading is on by default in EF 4, it is relatively inefficient in any ORM (causes many DB queries). You may still want to use projection or eager loading instead.