UserManager.RemoveFromRolesAsync and UserManager.IsInRoleAsyn return user not in role

York Bush 1 Reputation point
2022-11-16T19:02:13.257+00:00

I have a small project generated using vscode and dot net 7 core focused on Identity operations.

-- dotnet core project under parallels windows 11 on an M1 max macbook
-- Docker container running azure edge with a database simply for testing identity
-- program.cs setup
-- migrations generated and applied to the database
-- Identity tables are created and present in the database
-- able to create a User in the the Users table
-- able to create a Role in the Roles table
-- able to associate the user with the roles and a relationship row appears in the UserRoles table
-- able to retrieve the user and user rolls with

     var user = await _userManager.FindByEmailAsync(email);  
          
     var roles = await _userManager.GetRolesAsync(user);  

-- unable to use

    var role_result = await _userManager.IsInRoleAsync(user, roleName);  
    var result = await _userManager.RemoveFromRolesAsync(user, roleName);  

    both of these api calls return false with an error "user not in role".   I have done a bit of sanity checking and can't seem to see anything obvious.    
 

-- Are there any tools/utilities I can use out of the box to test the basic setup for Identity.
-- Suggestions on gathering additional debug information ?

Thank you!

Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
610 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,371 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,162 questions
{count} votes