Sunday, October 14, 2012

The object cannot be attached because it is already in the object context.

I have solved this error .If the object is already attached, simply put EntityState to Unchanged. Namespaces :C#
using System.Data
C#
_context.ObjectStateManager.ChangeObjectState(requisitionEdit, EntityState.Unchanged);
_context.Attach(requisitionEdit);
_context.ObjectStateManager.ChangeObjectState(requisitionEdit, EntityState.Modified);
If have any query then feel free ask me

No comments:

Post a Comment