简体   繁体   English

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

[英]Entity Framework multiple object relations to same column

I have couple of entities such as Customer , Vendors , Employee and I have another entity to handle Transaction Head , check definition here: 我有几个实体,例如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; }
}

And now when I create migration, it automatically ignores the To property from TransactionHead entity. 现在,当我创建迁移时,它会自动忽略TransactionHead实体的To属性。 So what is the solution? 那么解决方案是什么?

Thanks 谢谢

No. EF doesn't support this because it would require dynamic column type in the database. 否。EF不支持此功能,因为它需要数据库中的dynamic列类型。 the object property that EF will always ignore. EF将始终忽略的object属性。 you can find more information about complex type in EF in this link. 您可以在链接中找到有关EF中复杂类型的更多信息。

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

相关问题 到同一个表的多个0..1关系实体表 - Multiple 0..1 relations to same table Entity Framework code first 实体框架ICollection中的多个关系? - Multiple relations in Entity Framework ICollection? 实体框架6:克隆对象和关系(ID除外) - Entity Framework 6: Clone object and relations except ID 实体框架多个一对一关系 - Entity framework multiple one-to-one relations 当我需要具有相同类型的多个关系时,实体框架问题 - Entity Framework issues when I need to have multiple relations of the same type 实体框架(Database-First)与同一个表命名约定控件的多个关系 - Entity Framework (Database-First) multiple relations to same table naming conventions control 同一列外键引用实体框架中的多个表 - Same column foreign key referencing multiple tables in Entity Framework 在同一列上具有多个外键的实体框架核心 - Entity Framework Core with Multiple Foreign Key On Same Column 实体框架 - 由同一列中的多个条件选择 - 引用表 - Entity framework - select by multiple conditions in same column - referenced table 实体框架 - 由同一列中的多个条件选择 - 多对多 - Entity framework - select by multiple conditions in same column - Many to Many
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM