Trying to delete user:
public async Task<ActionResult> Delete(string id) { ApplicationUser user = await userManager.FindByIdAsync(id); if (user != null) { IdentityResult result = await userManager.DeleteAsync(user); if (result.Succeeded) { return RedirectToAction("Index"); } else { TempData["Error"] = "Error!"; return RedirectToAction("Index"); } } TempData["Error"] = "Error!"; return RedirectToAction("Index"); } User is not deleted. An error occurs:
System.Data.Entity.Infrastructure.DbUpdateException : See the inner exception for details. ---> System.Data.Entity.Core.UpdateException : See the inner exception for details. ---> System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_dbo.ClientProfiles_dbo.AspNetUsers_Id". The conflict occurred in the database "Schedule", table "dbo.ClientProfiles", column 'Id'. The statement has been terminated.
I tried to delete the role first, and then the user himself, but the error still occurs. How to fix it?