title: EF Core Fluent API Configuration Prevents TPC Inheritance
body: <p>I have models which inherit from each other, but I am struggling to get the fluent api configuration to behave as I want it to. Let's say I have a base class which defines some core properties</p>
  
  <pre><code>public class Entity
  {
     public int Id { get; set; }
     public string Title { get; set };
  }
  </code></pre>
  
  <p>And a subclass for Book</p>
  
  <pre><code>public class Book : Entity
  {
      public int Edition { get; set; }
  }
  </code></pre>
  
  <p>This way I can have books, magazines, pamphlets, comics, speeches etc, all inheriting from my Entity, and not have to define the relationship on every class.</p>
  
  <p>Now I add my DbSets to the DbContext like this</p>
  
  <pre><code>public class ApplicationDbContext : DbContext
  {
     public virtual DbSet&lt;Book&gt; Books { get; set; }
     public virtual DbSet&lt;Magazine&gt; Magazines { get; set; }
     public virtual DbSet&lt;Comic&gt; Comics { get; set; }
  }
  </code></pre>
  
  <p>And finally I add-migration Initial.</p>
  
  <p>My migration now creates separate tables (TPC) for each type. Perfect.</p>
  
  <p>The problem comes when I try to configure my base class using fluent API.</p>
  
  <p>I add a configuration for Entity</p>
  
  <pre><code>class EntityConfiguration : IEntityTypeConfiguration&lt;Entity&gt;
  {
      public void Configure(EntityTypeBuilder&lt;Entity&gt; builder)
      {
         builder.HasKey(e =&gt; e.Id);
         builder.Property(e =&gt; e.Title).IsRequired();
      }
  } 
  </code></pre>
  
  <p>The idea being that I will now only need to configure the base Entity, and all tables for the subclasses should pick up the configuration.</p>
  
  <p>I add my configuration to the DbContext OnModelCreating method.</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder modelBuilder)
  {
     base.OnModelCreating(modelBuilder);
     modelBuilder.ApplyConfiguration(new EntityConfiguration());
  }
  </code></pre>
  
  <p>When I add-migration, I end up with this</p>
  
  <pre><code>migrationBuilder.CreateTable(
                  name: "Entity",
                  columns: table =&gt; new
                  {
                      Edition = table.Column&lt;int&gt;(nullable: true),
                      Name = table.Column&lt;string&gt;(nullable: true),
                      Id = table.Column&lt;int&gt;(nullable: false)
                          .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                      Discriminator = table.Column&lt;string&gt;(nullable: false),
                      Title = table.Column&lt;string&gt;(nullable: false),
                      Frequency = table.Column&lt;int&gt;(nullable: true)
                  },
                  constraints: table =&gt;
                  {
                      table.PrimaryKey("PK_Entity", x =&gt; x.Id);
                  });
  </code></pre>
  
  <p>By trying to configure the base class, EF is now going down the TPH route, and creating a single table for Entity with a discriminator column.</p>
  
  <p>Is there a way to avoid this? Is it even possible to configure the base class and have all concrete tables pick up the configuration on the base class but create tables for the subclasses?</p>
  
  <p>NOTE: I have tried configuring the Entity directly in the DbContext OnModelCreating method, instead of using a separate configuration class, but this behaves just the same.</p>
  
  <p>The EF Core docs actually say TPC is not supported, which is strange because it does create separate tables for the subclasses until I try to configure the base class.</p>
  
  <p>I have tried using Ignore() to suppress the TPH but this has no effect.</p>
  
  <p>Example given is not real-world. My actual project has many more classes which all have common properties and relationships, so I want to avoid having to configure the same things over and over again.</p>