c # – Terms & Conditions> IdentityRole & # 39;

System.AggregateException: & # 39; One or more errors have occurred. (No service for type "Microsoft.AspNetCore.Identity.RoleManager") 1[Microsoft.AspNetCore.Identity.IdentityRole]& # 39; was registered.) & # 39;

InvalidOperationException: No service for type "Microsoft.AspNetCore.Identity.RoleManager" 1[Microsoft.AspNetCore.Identity.IdentityRole]& # 39; was registered.

inserir a Descrição da imagem aqui

Get the first delivery, such as the Método através de:

CreateRoles (serviceProvider) .Wait ();

Chamo o seguinte método:

private async task CreateRoles (IServiceProvider service provider)
{
var roleManager = serviceProvider.GetRequiredService <role manager> ();

var userManager = serviceProvider.GetRequiredService <UserManager> ();

line[] Role Names = {"Admin", "Concierge", "Residents"};

Identity Result result;

foreach (var namesole in role names)
{
var roleExist = await roleManager.RoleExistsAsync (namesRole);
if (! roleExist)
{
Result = Expect RolleManager.CreateAsync (new IdentityRole (NamesRole));
}
}
}