Search code examples
c#asp.net-mvcvisual-studioasp.net-coreasp.net-core-identity

No service for type UserIdentity has been registered


I have a web application where I want to integrate ASP.NET Core Identity but after adding controllers and views and editing the _Layout.cshtml I get this error:

InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.SignInManager`1[StrikeNet.EntityFramework.Entities.UserIdentity]' has been registered.

When I search for this error on Google or on here I only get the solution to rename all instances of IdentityUser to the name I have given, being UserIdentity. Also, many solutions say I should find it in the _LoginPartial.cshtml file.

The problem is, I don't have a file in my solution called _LoginPartial.cshtml and when I use the ctrl + F search tool and search for IdentityUser I also get no results.

Any ideas on what could be the remaining problem?


Solution

  • I think you forgot to add Identity into Startup.cs configuration:

    services.AddIdentity<User, Role>(); // if you have roles