Hi, 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? TIA Armin asked 07 Oct '14, 09:25 Armin Back |
This has been fixed for build 16.0.0.2030. 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 PhilippeBert... |
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. answered 07 Oct '14, 13:54 PhilippeBert... |
So you are saying the OData producer cannot yet be put in that table "ErledigteArbeiten"?
Well, what I want to say is that the metadata which is generated from the OData producer is wrong because it can't be used (from Visual Studio).
IMO there are two options/solutions: either the OData producer checks if there is a conflict with a NavigationProperty Name and a table Name and then use some prefix (or postfix or whatever) for the NavigationProperty Name. Or I have the ability to change the name of the corresponding NavigationProperty in the osdl-file. IMHO the first option would be the prefered one.
Can you please post the metadata of a service that just has the above table? Also a translation of the error message into English may help. I only read English and French.
Have you tried providing an association in the OSDL? (Note: if you provide one association, you must provide all of them for the service)
Sorry, I just had tried to make a simple (German) word play - and failed, apparently:)
Sorry didn't get the joke ;-)
The error message in english should be something like:
Name ErledigteArbeiten can't be used in typ Engel.ErledigteArbeiten. Element names can't be the same as the implied typ.
I didn't tried to provide an association in the osdl file but when I get you right I have to provide it for all entities then. Due to the fact that I have over 100 foreign key references in my real service this wouldn't be an Option.
Currently I'm updating my virtual machine, so I have no access to the metadata ... but I will come back with the info as soon as the windows updates are installed.
And here are the metadata - copy and paste from IE is ugly but I hope you get the needed informatione.