c# - Entity Framework Concatenated Key in Lookup -


i have code first project , while designing project have come across problem has stumped me, here able propose solution. have 3 tables , had many many relationships each other. resolved many many using new entity look-up table in database.

enter image description here

the problem have entity framework won't allow me use entities of a,b , c in look-up entity wants me add id lookup table. mean allowing duplication of data, , not want this.

i have tried set key attribute within poco (not practice still tried) purist glad hear not work removed it.

public class abc {     [key]     [column(order=1)]     public virtual a { get; set; }      [key]     [column(order=2)]     public virtual b b { get; set; }      [key]     [column(order=3)]     public virtual c c { get; set; } } 

as did not work tried use mappings file , used following

public class abcmappings : entitytypeconfiguration<abc> {     public abcmappings()     {         haskey(x => new { a.id, b.id, c.id});     } } 

this fails reporting in both cases abc has no key defined. if can't because of ef guess have use id descried above know why can't or solution great.

when setting keys in poco following.

public class abc {     [key, foreignkey("a"), column(order=0)]     public int aid {get;set;}     [key, foreignkey("b"), column(order=1)]     public int bid {get;set;}     [key, foreignkey("c"), column(order=2)]     public int cid {get;set;}      public virtual a { get; set; }     public virtual b b { get; set; }     public virtual c c { get; set; } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -