Does Entity Framework 4 not support property automatic lazy loading for model-first entities?

Posted by KallDrexx on Stack Overflow See other posts from Stack Overflow or by KallDrexx
Published on 2010-05-18T00:13:46Z Indexed on 2010/05/18 0:20 UTC
Read the original article Hit count: 306

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?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about entity-framework-4