c # – How to make the inscription compatible with RoleManager

I have a project asp.net core 2.1 with Identity enabled, but after making some changes to the original users, I encounter some problems.

The mistake I get when I click Register as a new user is InvalidOperationException: Unable to resolve service for type Microsoft.AspNetCore.Identity.UI.Services.IEmailSender & # 39; when activating namespace.Website.Main.Areas.Identity.Pages.Account.RccisterModel & # 39;.

In the Register.cshtml.cs class, I see that IEmailSender is being injected, but I have not made any changes to that and I do not understand why this error occurs? Please help


public class Startup
public startup (IConfiguration configuration)
Configuration = configuration;

public IConfiguration Configuration {get; }

// This method is called by the runtime. Use this method to add services to the container.
public Void ConfigureServices (IServiceCollection services)
services.Configurer(options =>
// This lambda determines if the user's consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
services.AddDbContext(options =>
options.UseSqlServer (
Configuration.GetConnectionString ("DefaultConnection")));
services.AddHttpClient ();

services.AddMvc (). SetCompatibilityVersion (CompatibilityVersion.Version_2_1);


public static class RolesConfig
static async static, task InitialiseAsync (ApplicationDbContext context, IServiceProvider serviceProvider)
var roleManager = serviceProvider.GetRequiredService <RoleManager> ();
chain[] roleNames = {"Admin", "Report", "Search"};
foreach (var roleName in roleNames)
var roleExist = wait roleManager.RoleExistsAsync (roleName);
if (! roleExist)
wait roleManager.CreateAsync (new IdentityRole (roleName));

Any help is very appreciated! Thank you