1

これら 3 つのクラスを 1 つの EF テーブルにマップしようとしています。このシナリオでは、基本クラスに実際に基本エンティティ クラスがありますが、これが問題の原因ですか? デフォルトの動作が適切に処理されないシナリオをカバーする例は見つかりません。

基本クラス:

public abstract class Connection : Entity
{
    public override int Id { get; set; }
    public ContactEnums.ConnectionType Type { get; set; }
    public string Value { get; set; }
}

子クラス:

public class BusinessConnection : Connection
{
    [ForeignKey("Business")]
    public int BusinessId { get; set; }
    public Business Business { get; set; }
}


public class ContactConnection : Connection
{
    [ForeignKey("Contact")]
    public int ContactId { get; set; }
    public Contact Contact { get; set; }
}

エンティティ基本クラス:

public abstract class Entity : EqualityAndHashCodeProvider<Entity, int>
{
    public override int Id { get; set; }
    public string CreatedBy { get; set; }
    public DateTime CreatedDate { get; set; }
    public string UpdatedBy { get; set; }
    public DateTime UpdatedDate { get; set; }
    [NotMapped]
    public ObjectState ObjectState { get; set; }
}

結果のテーブル構造

4

0 に答える 0