By protocol, and by intuition, it should not be possible to specify a NavigationPropertyBinding for a containment navigation property.
Currently we support setting this, which could lead to unexpected behavior, including writing out NavigationPropertyBindings for containment navigation properties in CSDL.
Assemblies affected
OData Library 7.x
Reproduce steps
Call EdmNavigationSource.AddNavigationTarget(navProp,entitySet)
where navProp is a containment navigation proper and entitySet is an entity set defined within the container.
Expected result
An error should be thrown, or validation exception raised when validating the CSDL. Writing CSDL should never write out navigation property bindings for containment navigation properties.
Actual result
The call succeeds and writing the CSDL writes out the invalid navigation property binding for the contained navigation property.
Additional detail
In 7.4.3 you can also get this behavior if you call FindNavigationTarget for a containment navigation property, as that implicitly creates a target EdmContainedEntitySet. Subsequently writing out the CSDL writes out this navigation property binding (specifying itself as the target).
We can't actually throw an error because that would be a breaking change. We could/should make it a no-op and make sure that we never write out navigation property bindings for containment navigation properties.
By protocol, and by intuition, it should not be possible to specify a NavigationPropertyBinding for a containment navigation property.
Currently we support setting this, which could lead to unexpected behavior, including writing out NavigationPropertyBindings for containment navigation properties in CSDL.
Assemblies affected
OData Library 7.x
Reproduce steps
Call EdmNavigationSource.AddNavigationTarget(navProp,entitySet)
where navProp is a containment navigation proper and entitySet is an entity set defined within the container.
Expected result
An error should be thrown, or validation exception raised when validating the CSDL. Writing CSDL should never write out navigation property bindings for containment navigation properties.
Actual result
The call succeeds and writing the CSDL writes out the invalid navigation property binding for the contained navigation property.
Additional detail
In 7.4.3 you can also get this behavior if you call FindNavigationTarget for a containment navigation property, as that implicitly creates a target EdmContainedEntitySet. Subsequently writing out the CSDL writes out this navigation property binding (specifying itself as the target).
We can't actually throw an error because that would be a breaking change. We could/should make it a no-op and make sure that we never write out navigation property bindings for containment navigation properties.