我在为以下示例数据库模式(在SQL Server中)创建实体框架代码优先映射时遇到问题:

每个表都包含一个TenantId,它是所有(复合)主键和外键(多租户)的一部分.
A Company是a Customer或a Supplier,我尝试通过Table-Per-Type(TPT)继承映射对此进行建模:
public abstract class Company
{
public int TenantId { get; set; }
public int CompanyId { get; set; }
public int AddressId { get; set; }
public Address Address { get; set; }
}
public class Customer : Company
{
public string CustomerName { get; set; }
public int SalesPersonId { get; set; }
public Person SalesPerson { get; set; }
}
public class Supplier : Company
{ …Run Code Online (Sandbox Code Playgroud) .net inheritance entity-framework table-per-type ef-code-first