var user = await UserManager.FindByIdAsync(userId); await UserManager.AddClaimAsync(user.Id, new Claim("customClaimType", "customClaimValue"));
var user = await UserManager.FindByIdAsync(userId); await UserManager.AddClaimAsync(user.Id, new Claim(ClaimTypes.Role, "Admin"));In this example, we add a role-based claim to the user's identity using the ClaimTypes.Role constant as the claim type and "Admin" as the claim value. Package library: Microsoft.AspNetCore.Identity.