title: Remove User from Roles in ASP.NET Identity 2.x
body: <p>How can I remove User from Roles in ASP.NET Identity 2.x ?
  about adding role to user there is no problem but when I want to remove a role from a user I cannot.It should be mentioned that there is no exception or error!</p>
  
  <pre><code>//POST: Admin/User/Edit/5
      [AcceptVerbs(HttpVerbs.Post)]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; Edit([Bind(Prefix = "")]UserViewModel userViewModel, List&lt;int&gt; availableRoles)
      {
          if (ModelState.IsValid)
          {
              List&lt;int&gt; newListOfRolesIDs = availableRoles;
              List&lt;int&gt; oldListOfRolesIDs = UserBLL.Instance.GetRolesIDs(userViewModel.Id);
              List&lt;int&gt; deletedList;
              List&lt;int&gt; addedList;
              var haschanged = oldListOfRolesIDs.ChangeTracking(newListOfRolesIDs, out deletedList, out addedList);
              using (new EFUnitOfWorkFactory().Create())
              {
                  if (haschanged)
                  {
                      UserBLL.Instance.InsertRoles(addedList, userViewModel.Id);
                      UserBLL.Instance.DeleteRoles(deletedList, userViewModel.Id);
                  }
                  await UserBLL.Instance.UpdateAsync(userViewModel);
              }
              //ArticleBLL.Instance.UpdatePartial(articleViewModel,  m =&gt; m.Title);
              return RedirectToAction("Edit");
          }
          return View(userViewModel);
      }
  </code></pre>
  
  <p>Delete Role method:</p>
  
  <pre><code>public void DeleteRoles(List&lt;int&gt; deleteList, int? userId)
      {
          if (userId != null)
          {
              User user = UserManager.FindByIdAsync(userId.Value).Result;
              foreach (var i in deleteList)
              {
                  user.Roles.Remove(new UserRole { RoleId = i, UserId = user.Id }); // What's the problem?!
              }
          }
      }
  </code></pre>
  
  <p>Insert Role method:</p>
  
  <pre><code>public void InsertRoles(List&lt;int&gt; insertList, int? userId)
      {
          if (userId != null)
          {
              User user = UserManager.FindByIdAsync(userId.Value).Result;
              foreach (var i in insertList)
              {
                  user.Roles.Add(new UserRole { RoleId = i, UserId = user.Id });
              }
          }
      }
  </code></pre>