繁体   English   中英

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

[英]Entity Framework multiple object relations to same column

我有几个实体,例如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; }
}

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

谢谢

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM