c# - Many-to-many table as model with extra column -


i have code-first mvc4 c# application these 2 models

public class classroom {     public int id { get; set; }     public string classname { get; set; }     public virtual icollection<pupil> pupils { get; set; } }  public class pupil {     public int id { get; set; }     public string pupilname { get; set; }     public virtual icollection<classroom> classrooms { get; set; } } 

this part of context

modelbuilder.entity<location>()     .hasmany(l => l.classrooms)     .withmany(o => o.pupils)     .map(m => m.mapleftkey("pupilid")         .maprightkey("classroomid")         .totable("pupilclassroommm")); 

therefore there many-to-many table called "pupilclassroommm".

this worked fine, want add column pupilclassroommm-table. tried make model, add-migration doesn't it.

public class pupilclassroommm {     [key, column(order = 0)]     public int classroomid { get; set; }     [key, column(order = 1)]     public int pupilid { get; set; }     public bool isprimary { get; set; } } 

the error is:

"pupilclassroommm: name: entityset 'pupilclassroommm' schema 'dbo' , table 'pupilclassroommm' defined. each entityset must refer unique schema , table." 

how can add field existing many-to-many table (i don't want lose data).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -