InvalidOperationException: нет службы для типа «Microsoft.AspNetCore.Identity.UserManager [Microsoft] .AspNetCore.Identity.IdentityUser]' зарегистрирован.
Моя целевая платформа — netcoreapp2.1.
Это мой класс хранилища пользователей:
Код: Выделить всё
public class MyUserStore : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Код: Выделить всё
public class MyUserRole : IdentityRole
{
public string Description { get; set; }
}
Код: Выделить всё
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions
options): base(options) { }
}
Код: Выделить всё
public void ConfigureServices(IServiceCollection services)
{
services.Configure(options =>
{
// This lambda determines whether user 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.AddDefaultIdentity()
// .AddEntityFrameworkStores();
services.AddIdentity(cfg => {
cfg.User.RequireUniqueEmail = true;
}).AddEntityFrameworkStores();
services.AddTransient();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
Подробнее здесь: https://stackoverflow.com/questions/525 ... soft-aspne