I'm currently Setting up an OData-service with version 16.0.02003 and have a problem with a "self referencing" entity when creating the service reference in Visual Studio.
I have created a table like this:
The corresponding osdl-file is quite simple:
When I try to create a service reference in Visual Studio I get the following error:
Fehler 0042: Name ErledigteArbeiten kann nicht in Typ Engel.ErledigteArbeiten verwendet werden. Elementnamen dürfen nicht mit dem einschließenden Typ übereinstimmen.
Taking a look at the metadata there are two NavigationProperties one with Name "ErledigteArbeiten" and one with "FK_ErledigteArbeiten_ErledigteArbeitenParent". So it's clear that the first one leeds to the error.
IMO this is a bug in the odata producer code ... is there a workaround or what can I do to get this working?
asked 07 Oct '14, 09:25
This has been fixed for build 220.127.116.110. We now ensure that types can not have properties with the same name as the containing type.
Association names also could have the same name as a complex type or entity type. OSDL files with such name conflicts now produce errors and generated navigational properties and associations are given better names.
answered 23 Oct '14, 19:39
There is certainly an issue. The generation code allows the navigational property to have the same name as its containing property. While some OData clients are less strict, Visual Studio does not allow it.
The work around is to define all associations in the OSDL file.
I suggest you contact support to help us understand the impact of this issue.