如何解决此错误 Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException?

问题描述

留言:

数据库操作预计影响 1 行,但实际影响 0 行。

我正在尝试更新数据库中的用户信息,但出现此错误

public IActionResult OnPost()
{
    if (!string.IsNullOrEmpty(user.Password))
    {
        PasswordHasher<User> Hasher = new PasswordHasher<User>();
        user.Password = Hasher.HashPassword(user,user.Password);
    }
    else
    {
        //user.Password = _mycontext.Users
        //    .SingleOrDefault(a => a.Id == user.Id).Password;
    }
    
    _mycontext.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
    _mycontext.SaveChanges();
    return Page();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)