entity framework - EF two one to many relations, something get wrong -


what trying do:

i have entity named 'department', , each department might have several translations different languages (e.g. "sales" on english, "sales" on german, etc).

also, each 'department' have synonyms in either language.

i want make number of available translations , synonyms flexible possible, since don't know ahead how translations or synonyms have each department.

therefore, idea this:

public class departmententity {     public departments id     {         get;         set;     }      public list<departmentnaming> names     {         get;         set;     }      public list<departmentnaming> synonyms     {         get;         set;     } }   public class departmentnaming {     public int id { get; set; }      public virtual departmententity department { get; set; }      public string name     {         get;         set;     }      public language language     {         get;         set;     } } 

this results in kind of bizarre table, have following columns:

[id]                   int            identity (1, 1) not null, [name]                 nvarchar (max) null, [language]             int            not null, [department_id]        int            null, [departmententity_id]  int            null, [departmententity_id1] int            null, 

basically, see one-to-many relation, since 1 particular department can have many translations, , 1 particular translation belongs 1 specific department (same synonyms).

so - why creates departmententity_id , departmententity_id1 me? miss? need somehow tell ef want achieve, don't know how...

thanks

as understood question , comment, name, synonym types departmentname

no need reference departmentname inside departmententity.

below design might in implementation, can rename classes in way match yours

// hold defualt department names public class department {     public int id{get;set;}     public string name{get;set;} }  // hold translation type: name or synonym public class translationtype {     public int id{get; set;}     public string name{get; set;} } // hold translation language name: en,gr... public class language {     public int id{get; set;}     public string name{get; set;} }  // hold translated name , type synonym or name public class translation {     public int id{get; set;}     public string name{get; set;}     public int languageid{get; set;}     public int translationtypeid{get;set;}      public language language{get; set;}     public translationtype translationtype{get; set;} }  // many many relation link departments translated languages public class departmenttranslation {            public department department{get; set;}     public translation translation{get; set;} } 

hope you


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -