EF Core 不支持复杂类型映射。
如果我有一个对象,例如:
public class Entity {
public string StringProp {get; set;}
public SubEntity NestedEntity {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
其中子实体是:
public class SubEntity{
public int IntProp {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我如何将其映射到包含 StringProp 和 IntProp 列的表。基本上表中的一条记录由实体和子实体的属性组成。
我试过忽略 SubEntity 并在 Entity 中公开它的属性,但这不起作用,因为当 NestedEntity 被忽略时,Entity 上使用其属性的任何属性都没有值。
除了创建具有复杂类型的所有属性的类或重构数据库之外,还有其他选择吗?