title: How to solve "Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager"?
body: <p>MVC client: ASP.NET CORE 3 Identity (with scaffolded Identity).
  Identity Server 4 (v3).  </p>
  
  <p>Created by <a href="https://identityserver4.readthedocs.io/en/latest/quickstarts/2_interactive_aspnetcore.html" rel="nofollow noreferrer">quickstart</a>.</p>
  
  <p>MVC client Startup has:</p>
  
  <pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
      .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
      .AddDefaultTokenProviders();
  </code></pre>
  
  <p>AddIdentity helps me register new user.</p>
  
  <p>When I'm trying MVC client sign in with Identity Server,  I get infinite loop. I <a href="https://stackoverflow.com/a/56741599/4205374">read</a>, that need to remove AddIdentity, because my Client connecting to Id Server. 
  When I remove AddIdentity a login works perfectly. </p>
  
  <p>But my MVC client has scaffolded Identity for User Registration. When I'm trying open User register form (<a href="http://localhost:5002/Identity/Account/Register" rel="nofollow noreferrer">http://localhost:5002/Identity/Account/Register</a>), I get error:</p>
  
  <pre><code>InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]' while attempting to activate 'UserRegistration.Areas.Identity.Pages.Account.RegisterModel'.
  </code></pre>
  
  <p>When I try to register without Identity UserManager:</p>
  
  <pre><code> services.AddScoped&lt;UserManager&lt;ApplicationUser&gt;&gt;();
   services.AddScoped&lt;SignInManager&lt;ApplicationUser&gt;&gt;();
  </code></pre>
  
  <p>I get other error:</p>
  
  <pre><code>Unhandled exception. System.AggregateException: Some services are not able to be constructed 
  (Error while validating the service descriptor 'ServiceType: 
  Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser] 
  Lifetime: Scoped ImplementationType: Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]': 
  Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[SharedIdentity.Models.ApplicationUser]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]'.) 
  (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Identity.SignInManager`1[SharedIdentity.Models.ApplicationUser] Lifetime: Scoped ImplementationType: Microsoft.AspNetCore.Identity.SignInManager`1[SharedIdentity.Models.ApplicationUser]': Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[SharedIdentity.Models.ApplicationUser]' 
  while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]'.)
   ---&gt; System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser] Lifetime: Scoped ImplementationType: Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]': 
  
  Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[SharedIdentity.Models.ApplicationUser]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]'.
   ---&gt; System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[SharedIdentity.Models.ApplicationUser]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]'.
  
  ......
  System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore`1[SharedIdentity.Models.ApplicationUser]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager`1[SharedIdentity.Models.ApplicationUser]'.
     at
  </code></pre>
  
  <p>Maybe I'm on wrong way? I need, that my MVC client can register users, and can login users with Identity Server.</p>