I made a similar example Many-To-Many Generic Update Method with Entity Framework 6 1
But in my case, the values of the properties of the collection are re-created in database.
public void Update(T updateItem, string property)
{
using (var databaseContext = new TelesystemContext())
{
T foundDal = databaseContext.Set<T>().Find(updateItem.Id);
var entry = databaseContext.Entry(foundDal);
entry.CurrentValues.SetValues(updateItem);
var collection = entry.Collection(property);
collection.Load();
collection.CurrentValue = typeof(T).GetProperty(property).GetValue(updateItem);
databaseContext.SaveChanges();
}
}
The property is re-created when is saved updateItem, instead of adding to the table - a bunch of "many-to-many".