Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Containment navigation properties shouldn't have NavigationPropertyBindings to non-containment sets #1138
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.
OData Library 7.x
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.
The call succeeds and writing the CSDL writes out the invalid navigation property binding for the contained navigation property.
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.