Getting "Optimistic concurrency crash, object has been changed." in Entity Framework 6 Identity

When I try to update the identifier from two parallel threads, I get and IdentityResultthat contains this error message:Optimistic concurrency failure, object has been modified.

I want to update the model and try again. Something like that.

var result = await UserManager.AddClaimAsync(memberIdentity, new Claim("abc", "cde"));
if(!result.Succeeded)
{
   //reload identity or context

   //retry
   await UserManager.AddClaimAsync(memberIdentity, new Claim("abc", "cde"));
}

Any ideas on how I will reload the identity or context?

+4
source share

All Articles