EF Core 5代码继承没有数据库继承#26741



我有两个EF模型:

public class Child: BaseClass
{ 
public string SomeProp {get; set;}
}
[Table("TableName")]
public absctract class BaseClass
{
public int ID {get; internal set;}
... some other properties and navigation collections...
}

我只有一张桌子";TableName";所有列从";BaseClass";以及";"孩子";类,我会使用"Child"类型来访问该表。但是,当我试着去做的时候,我得到了一个例外:"列名"鉴别器"无效"有了EF 6,我就能做到。

鉴别器是EF Core区分的方法。层次结构中的网络类型。

查看这些文章中每个传家宝部分的表格:https://learn.microsoft.com/en-us/ef/core/modeling/inheritance#table-每个层次结构和鉴别器配置https://blogs.dhrutara.com/blogs/efcore5-migrations-with-inheritance/

最新更新