public Task AddToRoleAsync(IdentityUser user, string roleName) { ThrowIfDisposed(); if (user == null) { throw new ArgumentNullException("user"); } if (string.IsNullOrWhiteSpace(roleName)) { throw new ArgumentNullException("roleName"); } return(Task.Run(() => { int roleId = UsersDb.IdentityRoles.Where(r => r.Name == roleName).Select(r => r.Id).Single(); UsersDb.InsertWithIdentity(new IdentityUserInRole() { UserId = user.Id, RoleId = roleId }); })); }