I want to assign a list of EXISTING CHILD obj Days to Course. But Im getting pk issues or duplicated rows. Since Days can be checked or unchecked, I should remove all first and finally add all.
Course()
{
int Id {get;set;}
string Descripcion {get;set;}
List<DayOfWeek> Days {get;set;}
}
DayOfWeek()
{
int Id {get;set;}
string Name {get;set;}
List<Course> Courses {get;set;} //Just for Entity Framework to create the many-to-many relation
}
SOME OTHER INFO
- code first
- lazy loading
- disconnected (repository/servide webapi layer, UI layer)
- entities and dto objects, e.g. Course is mapped to UI on CourseData and viceversa.
When I Attach a new object, it is set as ADDED, I need to fix that