1

我正在尝试将这三个类映射到一个 EF 表。在这种情况下,我的基类实际上有一个基 Entity 类,这会导致我的问题吗?我没有找到任何涵盖默认行为未正确处理的场景的示例。

基类

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