Entitiy Framework Complex Types

本文关键字:Types Complex Framework Entitiy | 更新日期: 2023-09-27 18:33:48

是否可以嵌套EF compex类型并在域实体中使用?

如果可能的话,复杂类型的父级和复杂型子级需要什么样的配置?

ComplexType Parent
{
 public ComplexTypeChild { get; set;}
 //other properties
}
ComplexTypeChild
{
 public string Name{ get; set;}
 //other properties
}
DomainEntity
{
 public ParentComplexType {get; private set; }
 //other properties and method
 }

提前谢谢你!

Entitiy Framework Complex Types

是的,这是可能的。

下面是您需要在 OnModelCreate 事件中添加的配置。

protected override void OnModelCreating(DbModelBuilder mb)
{
    mb.ComplexType<ComplexType>();
    mb.ComplexType<ComplexTypeChild>();
}