2017-05-04 93 views
0

我有幾個實體,如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屬性。那麼解決方案是什麼?

感謝

+0

**要**屬性的目的是什麼?爲什麼要命名**要**?爲什麼它是**對象**類型? –

回答

0

號EF不支持這一點,因爲它需要在數據庫中dynamic列類型。 EF始終忽略的object屬性。您可以在this鏈接中找到有關EF中複雜類型的更多信息。