title: "The entity type 'CustomAttributeData' requires a primary key to be defined" error when I add-migration in EF Core
body: <p>I put my models in a class library with Core. I already did the first migration to test a part of my model, but after a big enhancement, I deleted my database and migration to have only one V1 migration.</p>
  
  <p>The thing is, after this deletion, when I try to <code>add-migration</code> I get this error:</p>
  
  <pre><code>System.InvalidOperationException: The entity type 'CustomAttributeData' requires a primary key to be defined.
     at Microsoft.EntityFrameworkCore.Internal.ModelValidator.ShowError(String message)
     at Microsoft.EntityFrameworkCore.Internal.ModelValidator.Validate(IModel model)
     at Microsoft.EntityFrameworkCore.Internal.RelationalModelValidator.Validate(IModel model)
     at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
     at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
     at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
     at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceProvider.&lt;&gt;c__DisplayClass16_0.&lt;RealizeService&gt;b__0(ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceProvider.&lt;&gt;c__DisplayClass16_0.&lt;RealizeService&gt;b__0(ServiceProvider provider)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
     at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.&lt;&gt;c__DisplayClass3_0`1.&lt;Execute&gt;b__0()
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  The entity type 'CustomAttributeData' requires a primary key to be defined.
  </code></pre>
  
  <p>I don't know why I am getting this error. All my models have a primary key defined with <code>DataAnnotation</code>.</p>
  
  <p>If needed, I can provide the new models.</p>
  
  <p>Here's the context if is related/helpful:</p>
  
  <pre><code>public class AmcContext : DbContext
  {
      public DbSet&lt;User&gt; Users { get; set; }
      public DbSet&lt;Location&gt; Location { get; set; }
      public DbSet&lt;Rating&gt; Rating { get; set; }
      public DbSet&lt;RatingType&gt; RatingType { get; set; }
      public DbSet&lt;Subscription&gt; Subscription { get; set; }
      public DbSet&lt;Module&gt; Module { get; set; }
  
      public AmcContext(): base()
      {
  
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Ignore&lt;User&gt;();
          modelBuilder.Entity&lt;Client&gt;().ToTable("Client");
          modelBuilder.Entity&lt;Professionnal&gt;().ToTable("Professional");
  
          base.OnModelCreating(modelBuilder);
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=Askmycar;Trusted_Connection=True;");
  
          base.OnConfiguring(optionsBuilder);
      }
  }
  </code></pre>
  
  <p>Thanks.</p>