title: DbInitializer failed, key must be configured on the root type
body: <p>I recently migrated our .NET 1.1.4 code to .NET 2.0.0 Everything seems to work fine. Now, I tried adding a new model/table by doing:<br></p>
  
  <p><code>dotnet ef update</code></p>
  
  <p>I get the following exception:<br></p>
  
  <blockquote>
    <p>DbInitializer failed! A key cannot be configured on 'ApplicationUser' because it is a derived type. The key must be configured on the root type 'IdentityUser'</p>
  </blockquote>
  
  <p>I have an ApplicationUser that extends the IdentityUser and ApplicationRole that extends the IdentityRole, which is what some of the other tutorials/ stackoverflow posts say to do.<br></p>
  
  <p>I'm not sure what else I could be missing.<br></p>
  
  <p>In my ApplicationUser class I have:<br>
  <code>ICollection&lt;IdentityUserRole&lt;string&gt;&gt;</code><br></p>
  
  <p>Does that have to be of a custom type like ApplicationUserRole? What's the difference between IdentityUserRole and IdentityRole?<br></p>
  
  <hr>
  
  <p><strong>EDIT:</strong><br>
  I think it may be because in my context.cs file in <code>OnModelCreating</code> I have:<br></p>
  
  <pre><code>builder.Entity&lt;ApplicationUser&gt;()
      .ToTable("AspNetUsers")
      .HasKey(x =&gt; x.Id);
  </code></pre>
  
  <p>Here <code>Id</code> is inherited from <code>IdentityUser</code>.<br></p>
  
  <hr>
  
  <p><strong>EDIT2:</strong><br>
  So I commented out that line and that error goes away. It goes to the next line which is basically the same thing but for my ApplicationRole which extends  IdentityRole. I'm not quite sure what this means. Do i need to override the id property?<br></p>
  
  <hr>
  
  <p><strong>EDIT3:</strong><br>
  OK so I changed the types in the builder.Entity to just be <code>IdentityUser</code> and <code>IdentityRole</code>. Why does that fix it when in startup.cs I have to use <code>ApplicationUser</code> and <code>ApplicationRole</code> when calling <code>services.AddIdentity&lt;ApplicationUser, ApplicationRole&gt;</code></p>