N
Norm
The following seems like a simple enough operation, but for some
reason I can't figure it out.
In a parent-child relationship I want to move a child to a different
parent. I figured that it would be as easy as
"Parent.ChildCollection.Attach(ChildToTransfer)" but it doesn't work.
All of the entities are attached to the same object context and
already exist in the database. No inserting here, just updating.
At the time that ".SaveChanges()" is called on the container, the
states of the various entities are thus:
Parent.EntityState = Modified (Due to other code)
Parent.ChildCollection contains the ChildToTransfer
Child.Parent = The new Parent (correct)
BUT Child.EntityState = Unchanged
The parent gets updated, but the child record doesn't.
Any help would be appreciated and thanks in advance.
- Norm
reason I can't figure it out.
In a parent-child relationship I want to move a child to a different
parent. I figured that it would be as easy as
"Parent.ChildCollection.Attach(ChildToTransfer)" but it doesn't work.
All of the entities are attached to the same object context and
already exist in the database. No inserting here, just updating.
At the time that ".SaveChanges()" is called on the container, the
states of the various entities are thus:
Parent.EntityState = Modified (Due to other code)
Parent.ChildCollection contains the ChildToTransfer
Child.Parent = The new Parent (correct)
BUT Child.EntityState = Unchanged
The parent gets updated, but the child record doesn't.
Any help would be appreciated and thanks in advance.
- Norm