实体框架与同一列的多个对象关系

时间:2017-05-04 04:01:05

标签: c# asp.net-mvc wpf entity-framework

我有几个实体,例如CustomerVendorsEmployee,我有另一个实体来处理Transaction Head,请在此处查看定义:

public class TransactionHead
{
    public string DocumentNo { get; set; }
    public DocumentType TransactionType { get; set; }
    public Location From { get; set; }
    public object To { get; set; }//customer, supplier, location, employee "will have a discount table "
    public DateTime DocumentDate { get; set; }
    public float GrossAmount { get; set; }
    public float TotalDiscount { get; set; }
    public float NetAmount { get; set; }
    public int DetailRowCount { get; set; }
    public bool IsActive { get; set; }
    public bool IsDeleted { get; set; }
    public User Created { get; set; }
    public User Updated { get; set; }
    public User Approved { get; set; }
    public DocumentStatus DocumentStatus { get; set; }
    public string ApprovalRemark { get; set; }
    public string DocumentRemark { get; set; }
    public DateTime CreatedTimeStamp { get; set; }
    public DateTime UpdatedTimeStamp { get; set; }
}

现在,当我创建迁移时,它会自动忽略To实体的TransactionHead属性。那么解决方案是什么?

谢谢

1 个答案:

答案 0 :(得分:0)

没有。 EF不支持此功能,因为它在数据库中需要dynamic列类型。 EF将始终忽略的object属性。您可以在this链接中找到有关EF中复杂类型的更多信息。