0
由於我對EntityFramwork不太熟悉,所以我遇到了問題。我需要跟蹤哪個用戶創建了該交易以及哪個用戶修改了該交易。這意味着我有兩個屬性具有相同的類。實體框架:具有相同類問題的兩個屬性
這裏是交易類的屬性列表:
public virtual System.DateTime DateCreated { get; set; }
public virtual System.DateTime DateModified { get; set; }
public virtual bool IsDeleted { get; set; }
public virtual bool IsActive { get; set; }
public virtual string Description { get; set; }
public virtual User CreatedBy { get; set; }
public virtual User ModifiedBy { get; set; }
每當context.SaveChanges()
叫我得到以下異常:
Unable to determine the principal end of an association between the types 'Model.Entities.User' and 'Model.Entities.User'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
所以..顯示你流利的API /註釋映射? –
顯示爲您的映射,這兩個類可能指向對方,因此無法確定主體結束。 –