这是我的用户模型:
public User{
... (no navigation Property to modeltype)
}
以下模型的灵感来自 DocCode OrderDetails->Product,其中只有 OrderDetail 具有产品的外键。对于此配置,我从微风中收到一条错误消息:用户 SB 和 TL 的“导航属性错误”,但不适用于 MA。
public modeltype{
public DateTime? ClosedBySB { get; set; }
public long? SBId { get; set; }
[ForeignKey("SBId")]
public User SB { get; set; }
public DateTime? ClosedByTL { get; set; }
public long? TLId { get; set; }
[ForeignKey("TLId")]
public User TL { get; set; }
public DateTime? ClosedByMA { get; set; }
public long? MAId { get; set; }
[ForeignKey("MAId")]
public User MA { get; set; }
....
}
虽然这有效:
public modeltype{
public DateTime? ClosedBySB { get; set; }
//public long? SBId { get; set; }
//[ForeignKey("SBId")]
//public User SB { get; set; }
public DateTime? ClosedByTL { get; set; }
//public long? TLId { get; set; }
//[ForeignKey("TLId")]
//public User TL { get; set; }
public DateTime? ClosedByMA { get; set; }
public long? MAId { get; set; }
[ForeignKey("MAId")]
public User MA { get; set; }
....
}
我认为这应该工作?没有进行额外的 Fluent Api 配置。谢谢你的帮助。