0
我必須模擬2個實體:Book和Label。 Book類包含書籍信息和對包含標籤文本的Label類的引用。因此,我必須實現從Book類到Label類的單向導航,因爲當我想象一個圖書實體時,我想閱讀Label值,但是當我想象一個Label時,我不想獲取關於Book的任何信息。實體框架:帶數據註釋的單向導航
我發現很多Fluent API的例子,但我需要用Data Annotations來實現。有任何想法嗎?
public class Book
{
[Key]
public int id { get; set; }
public string Title { get; set; }
//What about label? How to navigate from Book to Label?
}
public class Label
{
[Key]
public int id { get; set; }
public string Name { get; set; }
}