No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered

This is the solution, in _LoginPartial.cshtml, replace

@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IndentityUser> UserManager

with

@using Microsoft.AspNetCore.Identity
@inject SignInManager<MyUserStore> SignInManager
@inject UserManager<MyUserStore> UserManager

Notice the difference, IdentityUser vs MyUserStore


When registering your own MyUserStore (bad name, should be MyUser) for the AspNetCore Identity, the UserManager<> type will be registered to the ServiceCollection as UserManager<MyUserStore>.

Whenever you want to resolve the UserManager<>, specify the identity user model registered in your startup as the type parameter. Which would be UserManager<MyUserStore> in your specific case:

This usually happens in the _LoginPartial.cshtml razor view. Eg.

@inject UserManager<IdentityUser> userManager

Must be changed to

@inject UserManager<MyUserStore> userManager

Or like-wise, when resolving it inside other classes, as may be the case in your Seeder service. The call stack of your exception should give you a hint of where this is happening.


Had same issue with core 2. One more area where you need to check is the file _ManageNav.cshtml. Try updating the line

@inject SignInManager<IdentityUser> SignInManager

with

@inject SignInManager<YOURCUSTOMMODEL> SignInManager