I am getting this error when I GetById() on an entity and then set the collection of child entities to my new list which comes from the MVC view.
The
I found this answer much more helpful for the same error. It seems that EF does not like it when you Remove, it prefers Delete.
You can delete a collection of records attached to a record like this.
order.OrderDetails.ToList().ForEach(s => db.Entry(s).State = EntityState.Deleted);
In the example, all of the Detail records attached to an Order have their State set to Delete. (In preparation to Add back updated Details, as part of an Order update)