terça-feira, 17 de outubro de 2023

Corrigir o erro: InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.RoleManager`1[Microsoft.AspNetCore.Identity.IdentityRole]' while attempting to activate

 builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)

    .AddRoles<IdentityRole>() // Corrigir o erro: InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.RoleManager`1[Microsoft.AspNetCore.Identity.IdentityRole]' while attempting to activate. Adicione esta linha

    .AddEntityFrameworkStores<ApplicationDbContext>();