【发布时间】:2015-01-23 11:35:27
【问题描述】:
我使用 EF6,这些是我的 POCO。
public class Author
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Book
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
public int Year { get; set; }
public decimal Price { get; set; }
public string Genre { get; set; }
// Foreign Key
public int AuthorId { get; set; }
// Navigation property
public Author Author { get; set; }
}
- 导航属性
Author的意义何在? - 将属性设为
virtual有什么意义? - 导航属性是否特定于实体框架?
编辑:经过更多研究,我找到了this thread,它很好地回答了我的第一个问题。
请大家帮忙解决最后两个问题吗?
【问题讨论】:
-
@MickyDuncan Embrace the non-Googlers。 Stack Overflow 问题通常最终成为搜索引擎中最热门的结果之一,因此将人们送回 Google 并没有帮助。
-
@Stijn 也许,但海报显示
no effort of prior research,此外,使用OP的确切标题What do navigation properties do in Entity Framework? -
真正的问题是要记住一个作者当然有一本书,但是一本书可以有多个作者吗? (就像作者可以写多本书一样):D 多对多是不好的 mmkay。
标签: c# entity-framework models