为什么这 #$*% 这么难?不应该。
两个表 Orders & Shippers:Orders.ship_via,一个 int 是 Shippers.ShipperId Shippers 的 FK。ShipperId 是 Shippers 上的 PK
我的实体:
public class Order : Entity
{
public int OrderId { get; set; }
public int ShipVia { get; set; }
//More properties
public virtual Shipper Shipper { get; set; }
}
public class Shipper : Entity
{
public int ShipperId { get; set; }
//More properties
}
当我运行它时,EF 尝试使用不存在的 Order.ShipperId 自然填充 Order.Shipper。
我不想使用注释。如何创建流畅的地图?
(注意:如果你想运行测试,我的测试环境使用 Northwind)。