表A
ID,MasterBID,XBID,YBID,ZBID,MasterCID,XCID,YCID,ZCID
表B
ID,NAME
表C
ID,Name
一个A里面有3个B,3个C,怎么用EF写他们的关系啊
modelBuilder.Entity<A>()
.HasRequired(b => b.MasterB)
.WithMany()
.HasForeignKey(b => b.BID);
modelBuilder.Entity<A>()
.HasRequired(b => b.C)
.WithMany()
.HasForeignKey(b => b.CID);
modelBuilder.Entity<A>()
.HasRequired(b => b.XB)
.WithMany()
.HasForeignKey(b => b.XBID);
modelBuilder.Entity<A>()
.HasRequired(b => b.YB)
.WithMany()
.HasForeignKey(b => b.YBID);
modelBuilder.Entity<A>()
.HasRequired(b => b.ZB)
.WithMany()
.HasForeignKey(b => b.ZBID);
modelBuilder.Entity<A>()
.HasRequired(b => b.XC)
.WithMany()
.HasForeignKey(b => b.XCID);
modelBuilder.Entity<A>()
.HasRequired(b => b.YC)
.WithMany()
.HasForeignKey(b => b.YCID);
modelBuilder.Entity<A>()
.HasRequired(b => b.ZC)
.WithMany()
.HasForeignKey(b => b.ZCID);