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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -