3
B和C之間
public class A
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Aid { get; set; }
public virtual ICollection<B> B { get; set; }
}
public class B
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Bid { get; set; }
[Key]
[Column(Order = 0)]
[Required]
Public virtual string BName {get ; set}
[Key]
[Column(Order = 1)]
[Required]
public virtual int Aid { get; set; }
[ForeignKey("Aid")]
public virtual A A { get; set; }
public virtual ICollection<C> C { get; set; }
}
public class C
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Cid { get; set; }
[Key]
[Column(Order = 0)]
[Required]
Public virtual string CName {get ; set}
[Key]
[Column(Order = 1)]
[Required]
public virtual int Bid { get; set; }
[ForeignKey("Bid")]
public virtual B B { get; set; }
}
關係困擾我.I不希望包括如BNAME在C類外鍵映射外鍵在EF代碼第一非主代理鍵柱
錯誤:數在從屬和主要角色的屬性 有關係的約束必須相同
我理解的錯誤,但我想指出C級只能通過投標,我怎麼能實現它,而不會干擾A之間的關係和B.