I created several users in the system. Adding goes without problems, but editing causes an error
DbUpdateConcurrencyException: Database operation expected to affect 1 row (s) but actually affected 0 row (s).
[HttpPost] [ValidateAntiForgeryToken] public IActionResult Edit(ApplicationUser applicationUser) { IdentityUser user; if (ModelState.IsValid && (user = _context.Users.SingleOrDefault(x => x.Id == applicationUser.Id)) != null) { user.UserName = applicationUser.UserName; //_context.Update(applicationUser); _context.SaveChanges(); return RedirectToAction("Index"); } return View(applicationUser); }
nugetpackage manager: Microsoft ASP.NET Identity Samples 2.1.0-alpha1 , so that the package is available in the list, do not forget to includeInclude prerelease, then study the example as work with asp.net-identity-2 - BaldUserAdminControllerin particular.Editmethod edits user - BaldUserManagermethods in your version, you’ll have to wrap them in the controller inside your asp.net-mvc application - Bald