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