title: Entity Framework and OnModelCreating()
body: <p>I am using the code first approach and I am trying to change the behavior of how EF creates my tables. I have two simple classes:</p>
  
  <p>Note: I have my database dropped and recreated every time. This wouldn't happen in the real world but for testing I am trying to intercept the creation and force EF to create the database how I envision it.</p>
  
  <pre><code>public class Person
  {
    public int PersonId { get; private set; }
    public string Forename { get; set; }
  }
  public class Officer : Person
  {
    public int OfficerId { get; private set; }
    public bool IsManager { get; set; }
  }
  </code></pre>
  
  <p>In my OnModelCreating() event I have the following:</p>
  
  <pre><code>    protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
  
          modelBuilder.Conventions.Remove&lt;PluralizingTableNameConvention&gt;();
  
  
          modelBuilder.Entity&lt;Person&gt;().HasKey(x =&gt; x.PersonId);
          modelBuilder.Entity&lt;Person&gt;().ToTable("Person");
          modelBuilder.Entity&lt;Officer&gt;().HasKey&lt;int&gt;(x =&gt; x.OfficerId);
          modelBuilder.Entity&lt;Officer&gt;().ToTable("Officer");
      }
  </code></pre>
  
  <p>Issue is when my database is created it creates the tables as:</p>
  
  <p>Table: Person
  PersonId INT PK
  Forename nvarchar(50)</p>
  
  <p>Table: Officer
  PersonId INT PK, FK
  IsManager BIT
  OfficerId INT</p>
  
  <p>To me this looks wrong as it doesn't go by traditional naming conventions, i.e. TableNameId.</p>
  
  <p>Any help on this is much appreciated.
  Thanks in advance, Onam.</p>