1

Closed

Multiple entity sets with same type is not supported for navigation property in derived type

description

Repro code attached.
Send request: GET http://localhost:50232/vehicles to repro the issue.

The exception is:
System.NotSupportedException occurred
HResult=-2146233067
Message=Cannot autoCreate binding because there are two or more candidate EntitySets.
Source=System.Web.Http.OData
StackTrace:
   at System.Web.Http.OData.Builder.EntitySetConfiguration.FindBinding(NavigationPropertyConfiguration navigationConfiguration, Boolean autoCreate) in d:\git\WebStackRuntime\src\System.Web.Http.OData\OData\Builder\EntitySetConfiguration.cs:line 207
InnerException:

If user explicitly sets binding to specified entity set, we shouldn't throw for multiple entity sets found. The problem is when adding navigation properties from derived types to base type, we use it's declared type to determine which entity set to bind, instead of the bindings user set in derived type.

file attachments

Closed Jan 18 at 9:43 PM by hongyes
Not supported scenario. Better exception is provided.

comments

raghuramn wrote Nov 7, 2012 at 6:49 PM

test defect. the error message is unclear in this case though which was fixed as a part of fix to issue 534. the new error message explains the underlying test issue,

"Cannot automatically bind the navigation property 'Vehicle' on entity type 'ODataRepro.Car' for the source entity set 'vehicles' because there are two or more matching target entity sets. The matching entity sets are
vehicles, anotherVehicles."