title: No service for type Identity.UserManager when using multiple identity users
body: <p><strong>My setup</strong></p>
  
  <p>Currently, I have two models that inherit from <code>ApplicationUser</code>, which inherits <code>IdentityUser</code>. The user classes are:</p>
  
  <pre><code>public abstract class ApplicationUser : IdentityUser
  {
      [PersonalData]
      public string FirstName { get; set; }
  
      [PersonalData]
      public string LastName { get; set; }
  
      [NotMapped]
      public string FullName =&gt; $"{FirstName} {LastName}";
  }
  
  public class StudentUser : ApplicationUser
  {
      [PersonalData]
      [Required]
      public string StudentNumber { get; set; }
  
      // A user belongs to one group
      public Group Group { get; set; }
  }
  
  public class EmployeeUser : ApplicationUser { }
  </code></pre>
  
  <p>The <code>ApplicationUser</code> contains <em>shared</em> properties, like the First and Last name. Both <code>StudentUser</code> and <code>EmployeeUser</code> have their <strong>own</strong> properties and relationships. This structure follows the <a href="https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/inheritance?view=aspnetcore-2.0#options-for-mapping-inheritance-to-database-tables" rel="nofollow noreferrer">Table Per Hierarchy (TPH)</a> inheritance. </p>
  
  <p>Ideally, I want to follow the <a href="https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/inheritance?view=aspnetcore-2.0#options-for-mapping-inheritance-to-database-tables" rel="nofollow noreferrer">Table Per Type (TPT)</a> inheritance, because the SQL structure is better. ASP.NET Core only supports TPH natively, so that is why I follow the TPT approach.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>I added the Identity service in <code>Startup.cs</code>:</p>
  
  <pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
  </code></pre>
  
  <p>When I call <code>UserManager&lt;StudentUser&gt;</code> or <code>UserManager&lt;EmployeeUser&gt;</code>, I get the following error:</p>
  
  <blockquote>
    <p>No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[ClassroomMonitor.Models.StudentUser]' has been registered.</p>
  </blockquote>
  
  <p><strong>My question</strong></p>
  
  <p>Unfortunately, I can't find much about this error combined with this implementation. </p>
  
  <p>Is it (even) possible to make it work this way?</p>
  
  <p>Any help or thoughts are welcome. </p>
  
  <p><strong>Update 1</strong></p>
  
  <p>Manually adding the <code>StudentUser</code> or <code>EmployeeUser</code> as a scoped services does not seem to work (mentioned as the first <a href="https://stackoverflow.com/a/52698155/3625118">answer</a>).</p>
  
  <pre><code>services.AddScoped&lt;UserManager&lt;ApplicationUser&gt;, UserManager&lt;ApplicationUser&gt;&gt;();
  // or..
  services.AddScoped&lt;UserManager&lt;ApplicationUser&gt;&gt;();
  </code></pre>
  
  <p>This throws the following error:</p>
  
  <blockquote>
    <p>InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore1[ClassroomMonitor.Models.StudentUser]' </p>
  </blockquote>
  
  <p><strong>Update 2</strong></p>
  
  <p>Here is a <a href="https://gist.github.com/matthijs110/94a55df9d4df35f2fb6596b54dedff25" rel="nofollow noreferrer">Gist</a> to give you a better picture of the project structue: </p>