Adding existing entity to navigation property of a different entity
- by Shay Friedman
I'm using EF4 and I'm running into a problem when I try to do something that looks quite trivial to me.
I have two entities, let's call them A and B. These entities have a many-to-many association between them with a navigation property on A that contains a list of related B entities.
What I want to do is to add existing B entities to a new A entity. When I try to do that, I get an exception:
AcceptChanges cannot continue because
the object's key values conflict with
another object in the
ObjectStateManager. Make sure that the
key values are unique before calling
AcceptChanges.
Has anyone run into such a problem?