How to make a triple relationship in code first Entity Framework -
how can make triple relationship in ef? i'm planning this:
table foo: (id int text varchar) table coo: (id int text varchar) table boo: (id int text varchar) table foocooboo: (fkfoo int fkcoo int fkboo int) i expected using code below achieved:
public class foo { public int id { get; set; } public string text { get; set; } public virtual icollection<boo> boos { get; set; } public virtual icollection<coo> coos { get; set; } } public class boo { public int id { get; set; } public string text { get; set; } public virtual icollection<foo> foos { get; set; } public virtual icollection<coo> coos { get; set; } } public class coo { public int id { get; set; } public string text { get; set; } public virtual icollection<boo> boos { get; set; } public virtual icollection<foo> foos { get; set; } } but output every icollection ef creates simple many many table. possible? create triple relationship using ef?
may be:
public class foocooboo { [key, foreignkey("foo")] public int fooid { get; set; } [key, foreignkey("coo")] public int cooid { get; set; } [key, foreignkey("boo")] public int booid { get; set; } public virtual foo { get; set; } public virtual boo { get; set; } public virtual coo { get; set; } } you have set navigation properties in configuration classes.
Comments
Post a Comment