为简单起见,我用简单的类重现了我的问题。我需要将1个ForegnKey映射到两个属性。 通过映射到Capital类 - 没问题,但我如何才能映射ArrivalCity?
class City
{
public int Id { get; set; }
[ForeignKey("Capital")]
public int CityId;
public String Name { get; set; }
public ArrivalCity ArrivalCity { get; set; }
public Capital Capital { get; set; }
}
public class ArrivalCity
{
[Key]
[Column(Order = 1)]
public int Id;
[Key]
[Column(Order = 2)]
public String Name { get; set; }
}
public class Capital
{
[Key]
public int Id;
public String Name { get; set; }
}