How do I delete a child entity from a parent collection with Entity Framework 4?
Posted
by simonjreid
on Stack Overflow
See other posts from Stack Overflow
or by simonjreid
Published on 2010-05-21T16:29:12Z
Indexed on
2010/05/21
16:30 UTC
Read the original article
Hit count: 352
entity-framework
|cascading-deletes
I'm using Entity Framework 4 and have a one-to-many relationship between a parent and child entity. I'm trying to delete a child using the parent repository by removing it from the parent's children collection:
public virtual void RemoveChild(Child child)
{
children.Remove(child);
}
When I try to save the changes I get the following error:
A relationship from the 'ParentChild' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding 'Child' must also in the 'Deleted' state.
Surely I don't have to delete the child entity explicitly using a child repository!
© Stack Overflow or respective owner