title: A key cannot be configured on 'ApplicationUser' because it is a derived type, but there is no key configuration on ApplicationUser
body: <p>I'm trying to customize IdentityUser using ApplicationUser, I followed the steps in microsoft article, but when I run the application, I get this error on method <code>base.OnModelCreating(modelBuilder);</code>:</p>
  
  <blockquote>
    <p>System.InvalidOperationException   HResult=0x80131509   Message=A key
    cannot be configured on 'ApplicationUser' because it is a derived
    type. The key must be configured on the root type 'IdentityUser'. If
    you did not intend for 'IdentityUser' to be included in the model,
    ensure that it is not included in a DbSet property on your context,
    referenced in a configuration call to ModelBuilder, or referenced from
    a navigation property on a type that is included in the model.<br>
    Source=Microsoft.EntityFrameworkCore   StackTrace:    at
    Microsoft.EntityFrameworkCore.Metadata.Internal.EntityType.SetPrimaryKey(IReadOnlyList<code>1
    properties, ConfigurationSource configurationSource)    at
    Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.PrimaryKey(IReadOnlyList</code>1
    properties, ConfigurationSource configurationSource)    at
    Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder.PrimaryKey(IReadOnlyList<code>1
    clrProperties, ConfigurationSource configurationSource)    at
    Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder</code>1.HasKey(Expression<code>1
    keyExpression)    at
    Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserContext</code>5.&lt;>c__DisplayClass20_0.b__0(EntityTypeBuilder<code>1
    b)    at
    Microsoft.EntityFrameworkCore.ModelBuilder.Entity[TEntity](Action</code>1
    buildAction)    at
    Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserContext<code>5.OnModelCreating(ModelBuilder
    builder)    at
    Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext</code>8.OnModelCreating(ModelBuilder
    builder)    at
    Assistente_de_Estagio.Data.ApplicationDbContext.OnModelCreating(ModelBuilder
    modelBuilder) in C:\Users\gui\source\repos\Assistente De
    Estágio\Assistente de Estagio\Data\ApplicationDbContext.cs:line 40<br>
    at
    Microsoft.EntityFrameworkCore.Infrastructure.ModelCustomizer.Customize(ModelBuilder
    modelBuilder, DbContext context)    at
    Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelCustomizer.Customize(ModelBuilder
    modelBuilder, DbContext context)    at
    Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext
    context, IConventionSetBuilder conventionSetBuilder, IModelValidator
    validator)    at
    Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.&lt;>c__DisplayClass5_0.b__1()
    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)</p>
  </blockquote>
  
  <p>Context code:</p>
  
  <pre><code>public partial class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public ApplicationDbContext()
      {
      }
  
      public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
          : base(options)
      {
      }
      public virtual DbSet&lt;Curso&gt; Curso { get; set; }
      public virtual DbSet&lt;Documento&gt; Documento { get; set; }
      public virtual DbSet&lt;OpcaoRequisito&gt; OpcaoRequisito { get; set; }
      public virtual DbSet&lt;ProgressoDoUsuario&gt; ProgressoDoUsuario { get; set; }
      public virtual DbSet&lt;Requisito&gt; Requisito { get; set; }
      public virtual DbSet&lt;RequisitoDeDocumento&gt; RequisitoDeDocumento { get; set; }
      public virtual DbSet&lt;RequisitoDeUsuario&gt; RequisitoDeUsuario { get; set; }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
      }
  </code></pre>
  
  <p>ApplicationUser.cs</p>
  
  <pre><code>public class ApplicationUser : IdentityUser
  {
  
  }
  </code></pre>