尝试从两个并行线程更新身份时,我收到包含此错误消息的IdentityResult
:Optimistic concurrency failure, object has been modified.
我想刷新模型并重试。 这样的事情。
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"));
}
关于如何重新加载身份或上下文的任何想法?