Message:
Database operation expected to affect 1 row(s) but actually affected 0 row(s).
I am trying to update user info in the database but I get this error.
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();
}
user
have a correct primary key value?