I have these models:
public class GroupSetCollection {
int Id { get; set; }
string Name { get; set; }
List<GroupSet> GroupSets { get; set; }
}
public class GroupSet {
int Id { get; set; }
string Name { get; set; }
List<Group> Groups{ get; set; }
}
Whenever I update the GroupSetCollection all the properties are updated except for the GroupSets. When I manually call the update on the GroupSet it gives me the following error.
Attaching an entity of type 'GroupSet' failed because another entity of the >same type already has the same primary key value for child.`
Below is the method I'm using to update the entities.
It fails at the GroupSet update and works fine on the GroupSetCollection update.
public void UpdateGroupSetCollection(GroupSetVM groupSetCollection)
{
_GroupSetCollectionService.Update(VMToEntity(groupSetCollection));
_GroupSet.Update(groupSetCollection.GroupSets);
}