I’m working on a new project and got some experience with Entity Framework 3.5. Now that I’m building the model and writing the first methods I notice that Entity Framework 4 seems to load every reference to which a navigation property exists. In 3.5 I had to manually .Include() each entity that was referenced if I wanted to access them. It even loads nested references. I’ve got 3 tables that look something like this:
Container(PK: container_Id, Name),
Text(PK: text_Id, FK: container_Id, Name),
Binary(PK: binary_Id, FK: text_Id, Name)
and if I do var containerList = Context.Container.ToList(); everything gets loaded, even down to the binary table.
Was this behavior changed or is there some options that I can use to disable this automatic loading of each and every reference?
Lazy loading was enabled by default in EF 4. You can disable the lazy loading.
Disable lazy loading by default in Entity Framework 4