title: Implement RemoveRange in Entity Framework
body: <p>I am trying to delete range of record from database and trying as following way:</p>
  
  <pre><code> public void DeleteAllRolesFromUser(int userId, FilterDto filter)
          {
              var unitOfWork = _serviceLocator.Resolve&lt;IUnitOfWork&gt;();
              var filterValidatorService = _serviceLocator.Resolve&lt;IFilterValidatorService&gt;();
  
              // Prep filter if properties are null
              filter = filterValidatorService.ValidateListFilter(filter);           
  
              var userRoles = GetUserRoles(userId, filter);
              var usersAllRoles = new List&lt;UserRole&gt;();
  
              foreach (RoleDto role in userRoles)
              {
                  var UserRole = new UserRole();
                  UserRole.RoleId = role.Id;
                  UserRole.UserId = userId;
                  usersAllRoles.Add(UserRole);
              }
              // Delete user role
              unitOfWork.UserRoles.RemoveRange(usersAllRoles);
  
              // Perform changes
              unitOfWork.SaveChanges();
          }
  </code></pre>
  
  <p>Where UserRole and RoleDto is like:</p>
  
  <pre><code>    public class UserRole : IdentityUserRole&lt;int&gt;, IModelWithId
          {
              public int Id {get; set; }
  
              public int UserId { get; set; }
              public virtual User User { get; set; }
  
              public int RoleId { get; set; }
              public virtual Role Role { get; set; }
          }
  public class RoleDto : IModelWithId
      {
          public int Id { get; set; }    
  
          public string Name { get; set; }    
  
          public string Description { get; set; }
  
          public bool Active { get; set; }
  
          public bool CanExport { get; set; }
  
          public int? UserCount { get; set; }
      }
  </code></pre>
  
  <p>I am getting error : The object cannot be deleted because it was not found in the ObjectStateManager.</p>