c# - EF Mapping multiple properties same table. The relationship '' was not loaded because the type '' is not available -
i have class multiple properties can mapped 1 table different type property. did don't have several tables same schema each property. follows:
public class flower : entity { public flower() { events = new collection<event>(); } public guid id { get; set; } public virtual user user { get; set; } public flowertype type { get; set; } public virtual extrainfobase family { get; set; } public virtual extrainfobase specie { get; set; } public virtual extrainfobase seller { get; set; } public string sellerobs { get; set; } public virtual extrainfobase localization { get; set; }
extrainfobase class can handle properties diferent type:
public class extrainfobase { public int id { get; set; } public infotype type { get; set; } public string value { get; set; } public string { get; set; } public virtual flower flower { get; set; } public virtual user user { get; set; } }
the mapping follows:
public class flowermap : entitytypeconfiguration<flower> { public flowermap() { this.haskey(t => t.id); this.totable("flowers"); this.property(t => t.id) .hascolumnname("id") .hascolumntype("uniqueidentifier"); this.property(t => t.type) .isrequired() .hascolumnname("type"); this.hasrequired(t => t.family).withrequiredprincipal(x => x.flower); this.hasrequired(t => t.gender).withrequiredprincipal(x => x.flower); this.hasrequired(t => t.specie).withrequiredprincipal(x => x.flower);` public class extrainfobasemap : entitytypeconfiguration<extrainfobase> { public extrainfobasemap() { this.haskey(t => t.id); this.totable("extrainfo"); this.property(t => t.id) .hascolumnname("id") .hasdatabasegeneratedoption(databasegeneratedoption.identity); this.property(t => t.type) .isrequired() .hascolumnname("type"); this.property(t => t.value) .isrequired() .hascolumnname("value"); this.property(t => t.extra) .hascolumnname("extra"); this.hasrequired(x => x.flower); this.hasrequired(x => x.user); } }
i'm getting error relationship 'flower_family' not loaded because type 'extrainfobase' not available. doing wrong? please advise.
sorry waste time. tired last night , possible solution came me in sleep. relations wrong. extrainfobase , flower have many many relation model wrong.
sorry.
Comments
Post a Comment