title: Entity Framework 6: one-to-one relationship with inheritance
body: <p>I'm using EF6 Code First and here's a simple model which reproduces my issue:</p>
  
  <pre><code>abstract class GeoInfo
  {
      public int Id { get; set; }
      public double CoordX { get; set; }
      public double CoordY { get; set; }
  }
  
  class PersonGeoInfo : GeoInfo
  {
      [Required]
      public Person Person { get; set; }
  }
  
  class CarGeoInfo : GeoInfo
  {
      [Required]
      public Car Car { get; set; }
  }
  
  class Person
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public virtual PersonGeoInfo PersonGeoInfo { get; set; }
  }
  
  class Car
  {
      public int Id { get; set; }
      public string Number { get; set; }
      public virtual CarGeoInfo CarGeoInfo { get; set; }
  }
  </code></pre>
  
  <p>And a context:</p>
  
  <pre><code>class MyContext : DbContext
  {
      public DbSet&lt;GeoInfo&gt; GeoInfos { get; set; }
      public DbSet&lt;PersonGeoInfo&gt; PersonGeoInfos { get; set; }
      public DbSet&lt;CarGeoInfo&gt; CarGeoInfos { get; set; }
      public DbSet&lt;Person&gt; Persons { get; set; }
      public DbSet&lt;Car&gt; Cars { get; set; }
  }
  </code></pre>
  
  <p>Entity Framework generates this database:</p>
  
  <p><img src="https://i.stack.imgur.com/TFRfa.png" alt="db schema"></p>
  
  <p>Look at <code>GeoInfoes</code> foreign keys constraints. They both are in one column and using this database is imposible. But EF didn't warned me, it just throws database exception: <code>The INSERT statement conflicted with the FOREIGN KEY...</code></p>
  
  <p>I've tried to use TPT strategy - the same problem, but mixing is between association and inheritance keys.</p>
  
  <p>I've tried to explicitly define foreign keys in model - didn't help. Nothing stops EF from generating a FK constraint in the same PK column.</p>
  
  <p>I can't create a base class for a <code>Car</code> and a <code>Person</code> because in real app they are already participate in another hierarchies.</p>
  
  <p>Am I using Entity Framework wrong or it really can't map one-to-one relationship along with inheritance to a database?</p>