问题描述
我首先使用实体框架代码来创建人员的家庭关系。
表为 People
和 Relationship
。
public class Person
{
public Person()
{
this.Relationships = new HashSet<Relationship>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Relationship> Relationships { get; set; }
}
public class Relationship
{
public Relationship()
{
this.People = new HashSet<Person>();
this.Relatives = new HashSet<Person>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Person> People { get; set; }
public virtual ICollection<Person> Relatives { get; set; }
}
要创建的表是
PersonRelationship (Person_Id,Relative_Id,Relationship_Id)
不知何故,它没有生成预期的 PersonRelationship
表。
谁能给点建议?
如果我尝试如下
public class Person
{
public Person()
{
this.Relationships = new HashSet<Relationship>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Relationship> Relationships { get; set; }
}
public class Relationship
{
public Relationship()
{
this.People = new HashSet<Person>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Person> People { get; set; }
}
RelationshipPersons
表将使用 RelationshipPersons (Person_Id,Relationship_Id)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)