title: Updating user by UserManager.Update() in ASP.NET Identity 2
body: <p>I use <code>ASP.NET Identity 2</code> in an <code>MVC 5</code> project and I want to update <code>Student</code> data by using <code>UserManager.Update()</code> method. However, as I inherit from <code>ApplicationUser</code> class, I need to map <code>Student</code> to <code>ApplicationUser</code> before calling update method. On the other hand, when using the approach that I also used for creating new Student, there is an error due to concurrency as I create a new instance rather than update. As I am bored to solve the problem using <code>AutoMapper</code>, I need a stable fix to solve the problem without <code>AutoMapper</code>. Could you please clarify me how to solve this problem? I pass the <code>StudentViewModel</code> to the Update method in the Controller and then I need to map it to Student and then pass them to the <code>UserManager.Update()</code> method as <code>ApplicationUser</code>. On the other hand I am wondering if I should retrieve and send the password on Controller stage instead of passing to View for security concern? Could you also inform me about this issue (during User Update I do not update password and I have to keep the user's password in the database). Any help would be appreciated.</p>
  
  <p><strong>Entity Classes:</strong></p>
  
  <pre><code>public class ApplicationUser : IdentityUser&lt;int, ApplicationUserLogin,
                                       ApplicationUserRole, ApplicationUserClaim&gt;, IUser&lt;int&gt;
  {
      public string Name { get; set; }
      public string Surname { get; set; } 
      //code omitted for brevity
  }
  
  public class Student: ApplicationUser
  {     
      public int? Number { get; set; }
  }
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public JsonResult Update([Bind(Exclude = null)] StudentViewModel model)
  {
      if (ModelState.IsValid)
      {
          ApplicationUser user = UserManager.FindById(model.Id);
  
          user = new Student
          {
              Name = model.Name,
              Surname = model.Surname,
              UserName = model.UserName,
              Email = model.Email,
              PhoneNumber = model.PhoneNumber,
              Number = model.Number, //custom property
              PasswordHash = checkUser.PasswordHash
          };
  
          UserManager.Update(user);
      }
  }
  </code></pre>