This has been driving me nuts for the last 2 days. I have 3 pretty basic classes (well, reduced for readability)
public class Employee
{
public string N
I ran into the same issue this morning, in my case I had an "Employee-Manager" association defined with a circular relationship. For example:
public class Employee
{
public string Name { set; get; }
virtual public Employee Manager { set; get; }
public Employee()
{
}
}
The app was crashing with the error above when setting the Manager property. At the end it turned out to be a bad implementation of the GetHashCode() method in the Employee class. It seemed that EF was not able to spot the modified entity since the comparison among the entities was failing; thus, EF was thinking the collection had been modified.