Net Identity

ANB 176 Reputation points
2022-11-10T21:28:09.257+00:00

I have a request where I need to return an IdentityUser + its role name.

I have a class that inherits from IdentityUser and add an extra property call "UserRole".

public class ApplicationUser : IdentityUser {
public string? UserRole { get; set; }
}

So when I run this line, I will have the message "Invalid column name 'UserRole'."
And this happen because I dont have this UserRole column in my AspNetUsers table, and I can't have it in there.

IEnumerable<ApplicationUser> users = _userManager.Users.Where(u => u.companyId==123);
foreach (var user in users)
{
user.UserRole = await _userManager.GetRolesAsync(user);
}

Any help ?
Thx

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,564 questions
No comments
{count} votes