运行 add-migration 时抛出异常(EF core 3.1.1):
CLR 属性“DiscriminatorLevel2Id”无法添加到实体类型“CustomerBase”,因为它是在 CLR 类型“InternalCustomer”上声明的
下图显示了所需的层次结构(简要):
映射看起来像:
// Discriminator (Level 1)
modelBuilder.Entity<CustomerBase>()
.HasDiscriminator(b => b.CustomerTypeId)
.HasValue<InternalCustomer>((int)CustomerType.Internal)
.HasValue<ExternalCustomer>((int)CustomerType.External);
// Discriminator (Level 2)
modelBuilder.Entity<InternalCustomer>()
.HasDiscriminator(b => b.DiscriminatorLevel2Id)
.HasValue<VIPCustomer>((int)DiscriminatorLevel2.VIP)
.HasValue<RegularCustomer>((int)DiscriminatorLevel2.Regular);
Run Code Online (Sandbox Code Playgroud)
Entity Framework Core 3.1.1 是否支持“多级继承 TPH”?