首先,我想说我确实经常看到这个问题。我知道可能有重复,但我已经搜索和搜索,但我没有找到正确的解决方案。
public class Members
{
public enum Statuses
{
APPLIED,
ACTIVE,
SUSPENDED,
DELETED
}
[Key]
public int ID { get; set; }
[Required]
public string UName { get; set; }
public int RecruiterID { get; set; }
public int AuditorID { get; set; }
public virtual ICollection<AuditorComments> AuditorComments { get; set; }
[Required]
public Statuses Status { get; set; }
[Timestamp]
public Byte[] Timestamp { get; set; }
[ForeignKey("RecruiterID")]
public virtual Members Recruiter { get; set; }
[ForeignKey("AuditorID")]
public virtual Members Auditor { get; set; }
}
基本上我把外键绑在一起了吗?
这是我收到的错误:
Unable to determine the principal end of an association between the types
'tn.Data.Members' and 'tn.Data.Members'. The principal end of this association
must be explicitly configured using either the relationship fluent API or data
annotations.
我有很多其他这样的桌子,但如果我能让这张桌子工作,那么我就能把它们都修好。