Loading Related POCO Entities
Because POCO entities do not have the same relationship requirements as objects that inherit from EntityObject, a slightly different process is required to load related objects. For general information about loading related objects, see Loading Related Objects and Loading Related Objects.
You can load objects that are related to POCO entities by using the following methods.
- Explicit Loading
Because the navigation properties of POCO entities are not required to return EntityCollection or EntityReference types, the explicit loading of related objects cannot be performed by using the Load method that these classes implement. Instead, you must explicitly load related objects by using the LoadProperty method of the ObjectContext class. The following example loads the related
Orderby calling the LoadProperty method with a supplied lambda expression that selects all items. For more information, see How to: Explicitly Load POCO Entities.
- Lazy Loading
- For a POCO entity to support lazy loading, it must meet requirements for lazy loading proxy creation, which is described in Requirements for Creating POCO Proxies. Lazy loading for POCO proxies is set in the same way as for other Entity Framework-generated entity types. For more information, see How to: Use Lazy Loading to Load Related Objects.
- Eager Loading
- You can specify query paths to return related POCO entities. Use the Include method to eagerly return related objects just like with tool-generated entity types. For more information see, How to: Use Query Paths to Shape Results.