我記得在EF navigation property should be virtual:導航屬性應該是虛擬的 - 在ef核心中不需要?
public class Blog
{
public int BlogId { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Tags { get; set; }
public virtual ICollection<Post> Posts { get; set; }
}
但我看EF Core並沒有看到它作爲虛擬:
public class Student
{
public int ID { get; set; }
public string LastName { get; set; }
public string FirstMidName { get; set; }
public DateTime EnrollmentDate { get; set; }
public ICollection<Enrollment> Enrollments { get; set; }
}
難道不是必需的了嗎?
如果它沒有特殊含義,爲什麼腳手架用虛擬生成每個導航屬性? –
@CamiloTerevinto以防萬一?默認?現在真的沒關係。 –
很有趣,其實我想知道他們是EF默認虛擬內核,我不這麼認爲 –