title: Table per Type in Entity Framework Core 2.0
body: <p>These are my models:</p>
  
  <pre><code>public class Company
  {
     public int CompanyId { get; set; }
     public string Name { get; set; }
     public string Address { get; set; }
     public string Email { get; set; }
     public string Url { get; set; }
     //...
  }
  
  public class HeadOffice : Company
  {
     public int HeadOfficeId { get; set; }
     public virtual List&lt;BranchOffice&gt; BranchOffice { get; set; } = new List&lt;BranchOffice&gt;();
  }
  
  public class BranchOffice : Company
  {
     public int BranchOfficeId { get; set; }
     public virtual HeadOffice HeadOffice { get; set; }
  }
  </code></pre>
  
  <p>I wanted the following database structure:</p>
  
  <p><strong>Table Company</strong></p>
  
  <ul>
  <li>CompanyId (PK)</li>
  <li>Name</li>
  <li>Address</li>
  <li>Email</li>
  <li>Url</li>
  </ul>
  
  <p><strong>Table HeadOffice</strong></p>
  
  <ul>
  <li>HeadOfficeId (PK)</li>
  <li>CompanyId (FK)</li>
  </ul>
  
  <p><strong>Table BranchOffice</strong></p>
  
  <ul>
  <li>BranchOfficeId (PK)</li>
  <li>HeadOfficeId (FK)</li>
  <li>CompanyId (FK)</li>
  </ul>
  
  <p>How can I do this?</p>
  
  <p>When I create this migration, the EF creates just one table, with all columns! I don't want this approach!</p>