如何在 EF 中定义具有不同主键和外键名称的一对多关系
更新
Public class Tb1
{
[Key]
public int ID{get; set;} // primary
**public int foreignKey{get; set;} //foreign key**
public string name{get; set;}
[Foreign("foreignKey")]
public virtual ICollection<Tb2> Tb2{ get; set; }
}
Public class Tb2
{
[Key]
public int ID {get; set;} //primary
public int tb1ID {get; set}
public string address {get; set;}
}
在这里,我想要主键上的一对多关系:外键在 TB1
外键:tb1ID 在 TB2
如何?