I\'m getting this error in Login Controller.
InvalidOperationException: Unable to resolve service for type \'Microsoft.AspNetCore.Identity.UserManager
Just to be clear about the answer:
If you use the class ApplicationUser
in startup.cs: services.AddIdentity
then you must use the same class in your controller when injecting it:
public AccountController(UserManager userManager)
If you use some other class such as:
public AccountController(UserManager userManager)
then you will get this error:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[IdentityUser]'
because you used ApplicationUser
in startup, not IdentityUser
so this type is not registered with the injection system.