【发布时间】:2018-11-09 19:03:59
【问题描述】:
我有 2 节课:
public class Item
{
public int Id { get; set; }
public string ItemName { get; set; }
}
public class ItemStats //inhenrit from Item
{
public int Id { get; set; }
public int MaxEnhanceLevel { get; set; }
public Item Item { get; set; }
}
这是一个 TPT,但由于它不支持开箱即用,我不能使用继承。我知道如何使用数据注释来实现这一点
[ForeignKey(nameof(Item))]
public int Id { get; set; }
但是我怎样才能通过 FluentAPI 做到这一点呢?我不想在我的实体类中添加数据注释。
【问题讨论】:
标签: c# entity-framework-core ef-core-2.0 ef-core-2.1