How to: Use Lazy Loading to Load Related Objects
This topic shows how to use lazy loading to load related objects. With lazy loading enabled, related objects are loaded when they are accessed through a navigation property. You can still eagerly load objects with the Include method or explicitly load them with the LoadProperty method. For more information, see Loading Related Objects.
In the Entity Framework runtime, the default value of the LazyLoadingEnabled property in an instance of ObjectContext is false. However, if you use the Entity Framework tools to create a new model and the corresponding generated classes, the generated code will set LazyLoadingEnabled to true in the constructor of the generated object context.
The example in this topic is based on the Adventure Works Sales Model. To run the code in this topic, you must have already added the Adventure Works Sales Model to your project and configured your project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard (Entity Framework) or How to: Manually Configure an Entity Framework Project and How to: Manually Define an Entity Data Model (Entity Framework).
The following example displays ten contacts and lets the user select one. Based on the selected contact the related orders are then loaded.