如何在流利的 ef 核心中定义一个映射到多个一对多共享超类型的列表 属性?

How to define one list property that maps to multiple one to manys of shared super type in fluent ef core?

首先我有一个 base class 这样的:

public class BaseModel
{
      public string Information { get; set; }
}

然后我有两个 sub classes of the base class:

public class SubType1 : BaseModel
{
    public int Id { get; set; }

    public int TestData1 { get; set; }

    public int ParentId { get; set; }

    public virtual Parent Parent { get; set; }
}


public class SubType2: BaseModel
{
    public int Id { get; set; }

    public string TestData2 { get; set; }

    public int ParentId { get; set; }

    public virtual Parent Parent { get; set; }
}

然后我有一个 parent class 有一个 list base class:

public class Parent
{
    public int Id { get; set; }

    public virtual List<BaseModel> Components { get; set; } = new List<BaseModel>();
}

Parent entitymany SubType1s 然后还有 many SubType2s

SubType1SubType2 每个都有自己的 table

什么是 fluent 我可以补充一点,它会自动在 Parent[=49] 上生成 Components 列表=] entity return 来自 SubType1SubType2 tables?

的所有实体

关键要求:需要流利

根据您的描述,您使用的似乎是Table per Concrete Type (TPC),对吧?

据我所知,在 EF 核心中,TPC 模式是 currently on the backlog,这意味着正在考虑将其作为一项功能包含在内,但尚未设置日期。