EF核心多对多表到另一个表

时间:2019-11-30 14:02:57

标签: entity-framework entity-relationship

我对使用EF Core的多对多表有疑问。

假设我有以下情况:

public class Book
{
    public int BookId { get; set; }
    public string Title { get; set; }
    public Author Author { get; set; }
    public ICollection<BookCategory> BookCategories { get; set; }
}  
public class Category
{
    public int CategoryId { get; set; }
    public string CategoryName { get; set; }
    public ICollection<BookCategory> BookCategories { get; set; }
}  
public class BookCategory
{
    public int BookId { get; set; }
    public Book Book { get; set; }
    public int CategoryId { get; set; }
    public Category Category { get; set; }
}

现在,假设我要再创建一个表“ Contracts”,该表应该是“ BookCategory”的子代。

如何建立这种关系?

0 个答案:

没有答案
相关问题