views:

133

answers:

1

All references that I find for lazy loading say it's possible but they all mention POCOs and that's it. I am using EF4 with the model-first methodology. In my model diagram I have a Project table and a UserObject table, with a 1 to many relationship between them. However, in code, when I have a valid UserObject and I attempt to get the project performing: Project prj = userobj.Project. Unfortunately, this doesn't work as it claims that UserObject.Project is null.

It seems like I have to explicitly load the Project object via calling UserObject.ProjectReference.Load() prior to calling .Project. Is there any way for this to occur automatically when I access the .Project property?

+1  A: 

This should work just fine. Right click on the EDMX, click Properties, check that Lazy loading enabled is set for the EDMX.

Hightechrider
I don't see a lazy loading option in any of the properties in the EDMX
KallDrexx
Found it. Apparently my domain model project was set for .net 3.5. Setting it to 4.0 enabled this option!
KallDrexx