【发布时间】:2015-10-13 07:11:16
【问题描述】:
我想在两个实体之间建立联系。
我有 Entity_1 和 Entity_2 的一对多关系(一个 Entity_1 可以有多个 Entity_2)。
所以我有我的实体: 实体
class Entity_1
{
public int Id { get; set; }
public int Entity_2Id{ get; set; }
public virtual Entity_2 Entity_2{ get; set; }
}
class Entity_2
{
public int Id { get; set; }
public int Entity_2Id{ get; set; }
public virtual ICollection<Entity_1> Entity_1s{ get; set; }
}
我如何才能建立我在实体 2 中有外键 (Entity_1) 的连接?
【问题讨论】:
标签: c# .net entity-framework mapping ef-fluent-api