Repro code is attached.
A <- B <- C
After adding A as entity type, I change C's base type to A. Then it reports following error:
System.InvalidOperationException occurred
HResult=-2146233079
Message=Cannot define keys on type 'ODataRepro.ExternalBug' deriving from 'ODataRepro.WorkItem'. Only the root type in the entity inheritance hierarchy can contain keys.
Source=System.Web.Http.OData
StackTrace:
at System.Web.Http.OData.Builder.EntityTypeConfiguration.HasKey(PropertyInfo keyProperty) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntityTypeConfiguration.cs:line 108
InnerException:
> System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntityTypeConfiguration.HasKey(System.Reflection.PropertyInfo keyProperty) Line 111 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.EntityKeyConvention.Apply(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity, System.Web.Http.OData.Builder.ODataModelBuilder model) Line 20 + 0xc bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.EntityTypeConvention.Apply(System.Web.Http.OData.Builder.IEdmTypeConfiguration edmTypeConfiguration, System.Web.Http.OData.Builder.ODataModelBuilder model) Line 20 + 0x11 bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.ApplyTypeAndPropertyConventions(System.Web.Http.OData.Builder.IStructuralTypeConfiguration edmTypeConfiguration) Line 585 + 0xf bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapType(System.Web.Http.OData.Builder.IStructuralTypeConfiguration edmType) Line 340 + 0xb bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.AddEntity(System.Type type) Line 124 + 0xb bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapDerivedTypes(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity) Line 238 + 0xe bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapEntityType(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity) Line 371 + 0xb bytes C#
Comments: http://aspnetwebstack.codeplex.com/SourceControl/changeset/5f5cfd0cb251
A <- B <- C
After adding A as entity type, I change C's base type to A. Then it reports following error:
System.InvalidOperationException occurred
HResult=-2146233079
Message=Cannot define keys on type 'ODataRepro.ExternalBug' deriving from 'ODataRepro.WorkItem'. Only the root type in the entity inheritance hierarchy can contain keys.
Source=System.Web.Http.OData
StackTrace:
at System.Web.Http.OData.Builder.EntityTypeConfiguration.HasKey(PropertyInfo keyProperty) in C:\dd\DevDiv\Offcycle\WPT\WebStackRuntime\runtime\src\System.Web.Http.OData\OData\Builder\EntityTypeConfiguration.cs:line 108
InnerException:
> System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntityTypeConfiguration.HasKey(System.Reflection.PropertyInfo keyProperty) Line 111 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.EntityKeyConvention.Apply(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity, System.Web.Http.OData.Builder.ODataModelBuilder model) Line 20 + 0xc bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.EntityTypeConvention.Apply(System.Web.Http.OData.Builder.IEdmTypeConfiguration edmTypeConfiguration, System.Web.Http.OData.Builder.ODataModelBuilder model) Line 20 + 0x11 bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.ApplyTypeAndPropertyConventions(System.Web.Http.OData.Builder.IStructuralTypeConfiguration edmTypeConfiguration) Line 585 + 0xf bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapType(System.Web.Http.OData.Builder.IStructuralTypeConfiguration edmType) Line 340 + 0xb bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.AddEntity(System.Type type) Line 124 + 0xb bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapDerivedTypes(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity) Line 238 + 0xe bytes C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.ODataConventionModelBuilder.MapEntityType(System.Web.Http.OData.Builder.IEntityTypeConfiguration entity) Line 371 + 0xb bytes C#
Comments: http://aspnetwebstack.codeplex.com/SourceControl/changeset/5f5cfd0cb251