"Student" has a navigation property "School".
public class Student
{
public long Id;
public string Name;
public School MySchool;
}
public class School
{
public long Id;
public string Name;
}
Client program passes in two Student entities of the same school to update database. Student.MySchool in the two Students are different objects with the same key School.Id.
How can I update the two Students in one transaction?
My thought was to attach the two Students to dbcontext then change their state to Modified. But the 2nd attaching failed with error: Attaching an entity of type 'School' failed because another entity of the same type already has the same primary key value.