Regression from 5.7 to latest: Unable to build model due to (incorrect) conflict detection - caused by the fix for Issue #427
Part of the change which was committed to fix Issue #427...
458 458 IList<EntityTypeConfiguration> actualEntityTypes =
459 - StructuralTypes.Except(misconfiguredEntityTypes).OfType<EntityTypeConfiguration>().ToList();
459 + StructuralTypes.OfType<EntityTypeConfiguration>()
460 + .Where(entity => entity.Keys().Any())
461 + .Concat(_explicitlyAddedTypes.OfType<EntityTypeConfiguration>())
462 + .ToList();
...is causing the following exception to be thrown for our model, which was not thrown in 5.7...
[InvalidOperationException: The entity type '<snip>' cannot be configured as a complex type because the derived type '<snip>' is already configured as an entity type.]
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +1668
System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) +966
System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) +237
System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(Type type) +128
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +1897
System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) +966
System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) +237
System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(Type type) +128
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +1897
System.Web.OData.Builder.ODataConventionModelBuilder.MapComplexType(ComplexTypeConfiguration complexType) +966
System.Web.OData.Builder.ODataConventionModelBuilder.MapType(StructuralTypeConfiguration edmType) +237
System.Web.OData.Builder.ODataConventionModelBuilder.AddComplexType(Type type) +128
System.Web.OData.Builder.ODataConventionModelBuilder.ReconfigureEntityTypesAsComplexType(EntityTypeConfiguration[] misconfiguredEntityTypes) +1897
System.Web.OData.Builder.ODataConventionModelBuilder.RediscoverComplexTypes() +336
System.Web.OData.Builder.ODataConventionModelBuilder.GetEdmModel() +315
<snip>.WebApiConfig.RegisterDiagTrack(HttpConfiguration config) +422
<snip>.WebApiConfig.Register(HttpConfiguration config) +9173
System.Web.Http.GlobalConfiguration.Configure(Action`1 configurationCallback) +43
<snip>.MvcApplication.Application_Start() +121
... which I tracked back to the above change for issue Issue #427 with Fan's help (I found the lines that changed to cause this to regress, he pointed out it was part of that commit). Since this is in reference to an internal MSFT data model, I am unable to post the repro here, but will follow up on internal email.
Thanks, Nick
Internal mail with repro zip sent.
Confirmed locally that https://github.com/xuzhg/WebApi/commit/a955debe022493b9dc5509fb2e6080e9797c0b4e does resolve the regression, looking forward to getting that merged in. Thanks!
PR #577 Merged f69f76e50232a653fc8d7dd51d3de9d247a110f2