Defining TPT Inheritances
In This Topic
No additional settings are to made for TPT hierarchies. Just register all classes using Entity methods and, if needed, specify the names of the tables the entities are mapped to. If the base entity class and its descendants have primary key columns with different names, the column name should be redefined using the ColumnName method of the PropertyConfiguration class or the Map method of the EntityConfiguration class.
builder.Entity<TptRoot>()
.FullTableName(@"TEST.TPTROOTS")
.PrimaryKey(p => p.Id);
builder.Entity<TptA>()
.FullTableName(@"TEST.TPTAS")
.Property(p => p.Id)
.ColumnName("A_ID");
builder.Entity<TptB>()
.FullTableName(@"TEST.TPTBS")
.Map(p => new { B_ID = p.Id });
builder.Entity<TptB1>()
.FullTableName(@"TEST.TPTB1S")
.Map(p => new { B1_ID = p.Id });
builder.Entity<TptB2>()
.FullTableName(@"TEST.TPTB2S")
.Map(p => new { B2_ID = p.Id });