title: No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered
body: <p>What is the possible cause of this error:</p>
  
  <blockquote>
    <p>InvalidOperationException: No service for type 'Microsoft.AspNetCore.Identity.UserManager [Microsoft.AspNetCore.Identity.IdentityUser]' has been registered.</p>
  </blockquote>
  
  <p>My target framework is <code>netcoreapp2.1</code>.</p>
  
  <p>This is my user store class:</p>
  
  <pre><code>public class MyUserStore : IdentityUser
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
  }
  </code></pre>
  
  <p>And my user role class:</p>
  
  <pre><code>public class MyUserRole : IdentityRole
  {
      public string Description { get; set; }
  }
  </code></pre>
  
  <p>My DbContext:</p>
  
  <pre><code>public class ApplicationDbContext : IdentityDbContext&lt;MyUserStore,MyUserRole,string&gt;
  {
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; 
        options): base(options) { }
  }
  </code></pre>
  
  <p>My <code>ConfigureServices</code> method in <code>Startup.cs</code>:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
      {
          // This lambda determines whether user consent for non-essential cookies is needed for a given request.
          options.CheckConsentNeeded = context =&gt; true;
          options.MinimumSameSitePolicy = SameSiteMode.None;
      });
  
      services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
          options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
      //services.AddDefaultIdentity&lt;IdentityUser&gt;()
      //    .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
  
      services.AddIdentity&lt;MyUserStore, MyUserRole&gt;(cfg =&gt; {
          cfg.User.RequireUniqueEmail = true;
      }).AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
      services.AddTransient&lt;Seeder&gt;();
      services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  }
  </code></pre>
  
  <p>i want to understand why this is happening and what is the best practice.</p>