我想做这样的事情:
context.Entry(oldEntity).CurrentValues.SetValues(newEntity);
我使用 EF 4.0,所以我知道我可以使用 EF 4.0context.ObjectStateManager
来实现相同的目标
我看不到任何设置值的方法。我有ChangeObjectState
, ChangeRelationshipState
,ChangeRelationshipState
可用的功能。
事实上我有这个错误:An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.
所以我需要修改实体而不是附加它来解决我的问题。