title: Cannot define keys on type 'User' deriving from 'People'. Only the root type in the entity inheritance hierarchy can contain keys
body: <p>I am using Web API 2.2 project with OData4 package + Entity Framework 6.</p>
  
  <p>I have a <code>User</code> class which inherits from <code>People</code> class. <code>People</code> class itself inherits from <code>Person</code> class.</p>
  
  <pre><code>[Table("People")]
  public class People : Person
  { }
  
  public class User: People
  {
     [Key]
     public int UserId { get; set; }
     [ForeignKey("Anonymous")]
     public int AnonymousId { get; set; }
  }
  </code></pre>
  
  <p>When I execute the code an exception is thrown in <code>WebApiConfig::Register</code> method on this line </p>
  
  <pre><code>config.MapODataServiceRoute(
          routeName: "ODataRoute",
          routePrefix: null,
          model: builder.GetEdmModel());
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>An exception of type 'System.InvalidOperationException' occurred in System.Web.OData.dll but was not handled in user code</p>
    
    <p>Additional information: Cannot define keys on type 'User' deriving from 'People'. Only the root type in the entity inheritance hierarchy can contain keys.</p>
  </blockquote>
  
  <p>I have tried solution given at 
  <a href="http://stack247.wordpress.com/2013/02/28/cannot-define-keys-on-type-deriving-from-only-root-type-in-entity-inheritance-hierarchy-can-contain-keys/" rel="nofollow">http://stack247.wordpress.com/2013/02/28/cannot-define-keys-on-type-deriving-from-only-root-type-in-entity-inheritance-hierarchy-can-contain-keys/</a></p>
  
  <p>but it did not work.</p>
  
  <p>I tried :</p>
  
  <pre><code>builder.EntityType&lt;User&gt;().DerivesFrom&lt;People&gt;();
  builder.EntityType&lt;People&gt;().DerivesFrom&lt;Element&gt;();
  </code></pre>