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?
This should work just fine. Right click on the EDMX, click Properties, check that Lazy loading enabled
is set for the EDMX.
精彩评论