0
如何为EF构建这些表?EF多对多
第一个表:
public class model1
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
二表:具有第一和第二 和几个字段的连接
public class model2
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
表:
public class model3
{
public int (id from model1){ get; set; }
public int (id from model2) { get; set; }
public int (id from model2){ get; set; }
public decimal Name{ get; set; }
public decimal Description{ get; set; }
}
ok,并且对于model1和model2我必须添加公共虚拟ICollection Model3s {get;组; }? –
user1600070
2013-04-24 12:36:21
我的背景 public DbSet model1s {get;组; } public DbSet model2s {get;组; } public DbSet model3s {get;组; } 从我如何可以得到像context.model1s的东西。 (和SecondModel2Id的名称) –
user1600070
2013-04-24 12:44:20
看看这个http://vincentlauzon.wordpress.com/2011/04/15/entity-framework-4-1-many-to-many-relationships-5/。多对多的关系在这里详细解释 – Chris 2013-04-24 12:48:37