I have this code:
...
var _context = new MyDbContext();
var _userManager = new UserManager<User>(new UserStore<User>(_context));
...
public bool IsInRole(string userId, string roleName)
{
return _userManager.IsInRole(userId, roleName); //InvalidOperationException
}
Throws this exception:
An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code
Additional information: Sequence contains more than one element
Visual Studio 2015
.NET 4.5
Microsoft AspNet Identity Core 2.2.1
Entity Framework 6
There are duplicated names in the IdentityRoles table:
SELECT *
FROM [dbo].[IdentityRoles]
Deleting the unnecessary rows solved the problem.