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
This type of solution did the trick for me:
Parent original = db.Parent.SingleOrDefault(t => t.ID == updated.ID);
db.Childs.RemoveRange(original.Childs);
updated.Childs.ToList().ForEach(c => original.Childs.Add(c));
db.Entry(original).CurrentValues.SetValues(updated);
Its important to say that this deletes all the records and insert them again. But for my case (less then 10) it´s ok.
I hope it helps.