Entity Framework: I set the foreign key, SaveChanges then access the navigation property, but it doesn't load the related entity. Why not?

前端 未结 4 1346
再見小時候
再見小時候 2020-12-02 10:50

I am using this Entity class with Entity Framework 5 Code First:

public class Survey
{
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public i         


        
4条回答
  •  悲哀的现实
    2020-12-02 11:22

    You need to define all the properties on the Survey class as virtual to enable lazy-loading.

    See http://msdn.microsoft.com/en-us/library/vstudio/dd468057(v=vs.100).aspx for more information.

提交回复
热议问题