📜  身份向用户添加角色 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:12.943000             🧑  作者: Mango

代码示例1
var user = new JobUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
    //add this to add role to user
     await UserManager.AddToRoleAsync(user.Id, "Name of your role");
}