How to fix Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager'
By FoxLearn 2/18/2024 9:40:58 AM 110
This post shows you how to solve System.AggregateException: 'Some services are not able to be constructed'
Inner Exceptions
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IRoleStore`1[Microsoft.AspNetCore.Identity.IdentityRole]' while attempting to activate 'Microsoft.AspNetCore.Identity.RoleManager`1[Microsoft.AspNetCore.Identity.IdentityRole]'.
You need to use the same user data model in SignInManager, UserManager.
Opening your Startup class, then modify your code as shown below.
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, ApplicationRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddCustomStores() .AddDefaultTokenProviders();
- ASP.NET Core: How to Create RDLC Report in ASP.NET Core
- How to fix Assets file 'project.assets.json' not found
- How to fix 'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
- How to fix 'DbContextOptionsBuilder' does not contain a definition for 'UseSqlServer'
- How to set cookie ValidationInterval in ASP.NET Core
- How to fix LoginPath not working in ASP.NET Core
- How to Configure ASP.NET Core Identity password policy
- How to fix System.InvalidOperationException: Scheme already exists: Identity.Application
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024
What Are RESTful Web Services?
02/19/2024