title: Entity Framework Table per Hierarchy not creating Discriminator
body: <p>I created an inheritance hierarchy after a few migrations. Now when I update the database using code first migrations, code-first is not automatically creating the discriminator field. I have since dropped the table and recreated it (using code-first migrations) without any luck. The only thing I can think of is that there are no additional "non-virtual" properties in the derived classes--the inheritance structure was created to enforce a business rule that only a certain derived type can have a relationship with another entity.</p>
  
  <p>Base Type:</p>
  
  <pre><code>public abstract class Process
  {
  
      private ICollection&lt;ProcessSpecification&gt; _specifications { get; set; }
  
      protected Process()
      {
          _specifications = new List&lt;ProcessSpecification&gt;();
      }        
  
      public Int32 Id { get; set; }
      public String Description { get; set; }
      public Int32 ToolId { get; set; }
  
      public virtual Tool Tool { get; set; }        
      public virtual ICollection&lt;ProcessSpecification&gt; Specifications
      {
          get { return _specifications; }
          set { _specifications = value; }
      }
  
  }
  </code></pre>
  
  <p>Derived class (no different/unique scalar properties):</p>
  
  <pre><code>public class AssemblyProcess : Process
  {
      private ICollection&lt;AssemblyProcessComponent&gt; _components;
  
      public AssemblyProcess()
      {
          _components = new List&lt;AssemblyProcessComponent&gt;();            
      }
  
      public virtual ICollection&lt;AssemblyProcessComponent&gt; Components
      {
          get { return _components; }
          set { _components = value; }
      }
  }
  </code></pre>
  
  <p>Another derived type</p>
  
  <pre><code>public class MachiningProcess : Process
  {
      private ICollection&lt;MachiningProcessFeature&gt; _features;
  
      public MachiningProcess()
      {
          _features = new List&lt;MachiningProcessFeature&gt;();
      }
  
      public virtual ICollection&lt;MachiningProcessFeature&gt; Features { get { return _features; } set { _features = value; } }
  }
  </code></pre>
  
  <p>Is code-first not adding the discriminator column in the database because it doesn't see any differences between the derived classes (because of there not being any unique "non-virtual" properties)? If so, how do I get around this? If not, what are some reasons why code-first would not automatically create the discriminator column in the database? I have another TPH structure that works exactly the way it's supposed to.</p>
  
  <p><strong>DbContext:</strong></p>
  
  <pre><code>public LineProcessPlanningContext()
          : base("LineProcessPlanning")
      {
      }   
  
  public DbSet&lt;Component&gt; Components { get; set; }
  public DbSet&lt;Customer&gt; Customers { get; set; }
  public DbSet&lt;Feature&gt; Features { get; set; }
  public DbSet&lt;OperationDefinition&gt; OperationDefinitions { get; set; }
  public DbSet&lt;PartDesign&gt; PartDesigns { get; set; }
  public DbSet&lt;Process&gt; Processes { get; set; }
  public DbSet&lt;ProcessPlan&gt; ProcessPlans { get; set; }
  public DbSet&lt;ProcessPlanStep&gt; ProcessPlanSteps { get; set; }
  public DbSet&lt;ProductionLine&gt; ProductionLines { get; set; }       
  public DbSet&lt;StationCycleDefinition&gt; StationCycleDefinitions { get; set; }
  public DbSet&lt;StationCycleStep&gt; StationCycleSteps { get; set; }
  public DbSet&lt;StationDefinition&gt; StationDefinitions { get; set; }
  public DbSet&lt;UnitOfMeasurement&gt; UnitsOfMeasurement { get; set; }        
  public DbSet&lt;Tool&gt; Tools { get; set; }
  </code></pre>
  
  <p>I also tried creating "dummy" properties that are unique to each derived type. Code migrations added the new properties as columns to the table, but the migration did not create a discriminator column.</p>