標準シナリオでは、TPHがデフォルトです。
TPTが必要な場合は、テーブル名を指定するだけです。あなたのケースでは
(私もいくつかのプロパティを追加しました)
//Not mapped to table, has all fields apart from foreign key
public abstract class FirstBaseModel
{
public int Id { get; set; }
}
//Mapped to a table, has foreign key (eg. customerId)
[Table("MyTable")]
public class Derived1Model : FirstBaseModel
{
public string D1 { get; set; }
}
//Mapped to a different table, has foreign key (eg. companyId)
[Table("MyDifferentTable")]
public class Derived2Model : FirstBaseModel
{
public string D2 { get; set; }
}
//Mapped to the same table as Derived2Model
[Table("MyDifferentTable")]
public class Derived3Model : Derived2Model
{
public string D3 { get; set; }
}
これは、EFはデータベース上
ExecuteNonQuery==========
CREATE TABLE [MyTable] (
[Id] int not null identity(1,1)
, [D1] text null
);
ALTER TABLE [MyTable] ADD CONSTRAINT [PK_MyTable_b9ce81de] PRIMARY KEY ([Id])
ExecuteNonQuery==========
CREATE TABLE [MyDifferentTable] (
[Id] int not null identity(1,1)
, [D2] text null
, [D3] text null
, [Discriminator] varchar(128) not null
);
ALTER TABLE [MyDifferentTable] ADD CONSTRAINT [PK_MyDifferentTable_b9ce81de] PRIMARY KEY ([Id])
を実行したクエリです