c# - Entity Framework - group multiple foreign keys into a single column -
new ef here , having difficulty.
i have 24 tables need create code-first. each 1 of these tables has around 2 - 10 many-to-one relationships simple , can represented 1 table. here few of classes illustrate structure...
namespace emrs { public class erecord { [key] public int pcrid { get; set; } public virtual list<efirstclass> efirstclass {get; set;} public virtual list<esecondclass> esecondclass { get; set; } } public class efirstelement { [key] public int elementid { get; set; } public elementcode stuff1 { get; set; } //eairway.06 public string stuff2 { get; set; } public int pcrid { get; set; } public virtual erecord ereportid { get; set; } public virtual list<subelement> stuff4list { get; set; } public virtual list<subelement> stuff5list { get; set; } public virtual list<subelement> stuff6list { get; set; } public virtual list<subelement> stuff7list { get; set; } } public class esecondelement { [key] public int elementid { get; set; } public elementcode stuff9 { get; set; } public elementcode stuff10 { get; set; } public int pcrid { get; set; } public virtual erecord ereportid { get; set; } public virtual list<subelement> stufflist11 { get; set; } public virtual list<subelement> stufflist12 { get; set; } public virtual list<subelement> stufflist13 { get; set; } public virtual list<subelement> stufflist14 { get; set; } public virtual list<subelement> stufflist15 { get; set; } public virtual list<subelement> stufflist16 { get; set; } public virtual list<subelement> stufflist17 { get; set; } } public class subelement { public int subelementid { get; set; } public string value { get; set; } public dynamic type { get; set; } public int elementid { get; set; } } }
if create class/table each individual 1 many relationship in element classes, end many tables same structure. have foreign key in subelement class references more 1 class.
i tried having parentelement abstract class , inheriting in of element classes ef created table class(parentelement) , placed columns in element classes within table.
is there way ef code first?
Comments
Post a Comment