Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.


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:

drop table if exists Stammdaten.ErledigteArbeiten;
create table Stammdaten.ErledigteArbeiten (
     GUID uniqueidentifier not null Default newid(),
     PARENTID uniqueidentifier null,
     BEZEICHNUNG varchar (60) ,
     TEXT Long varchar,
     contraint PK_ErledigteArbeiten Primary key (GUID),
alter table Stammdaten.ErledigteArbeiten
add foreign key FK_ErledigteArbeiten_ErledigteArbeitenParent (PARENTID)
references Stammdaten.ErledigteArbeiten (GUID)
on update restrict
on delete cascade;

The corresponding osdl-file is quite simple:

service Namespace "Engel" {
     entity "Stammdaten"."ErledigteArbeiten";

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

Armin%20Back's gravatar image

Armin Back
accept rate: 0%

So you are saying the OData producer cannot yet be put in that table "ErledigteArbeiten"?

(07 Oct '14, 10:39) Volker Barth

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.

(07 Oct '14, 10:49) Armin Back
Replies hidden

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)

(07 Oct '14, 11:16) PhilippeBert...
Replies hidden

Sorry, I just had tried to make a simple (German) word play - and failed, apparently:)

(07 Oct '14, 11:24) Volker Barth

Sorry didn't get the joke ;-)

(07 Oct '14, 11:28) Armin Back

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.

(07 Oct '14, 11:38) Armin Back

And here are the metadata - copy and paste from IE is ugly but I hope you get the needed informatione.

-<edmx:edmx version="1.0" xmlns:edmx="">

-<edmx:dataservices m:dataserviceversion="1.0" xmlns:m="">

-<schema xmlns:m="" namespace="Engel" xmlns="" xmlns:d="">

-<entitytype name="ErledigteArbeiten">


<propertyref name="GUID"/>


<property name="GUID" nullable="false" type="Edm.Guid"/>

<property name="MANDANTNR" nullable="false" type="Edm.Decimal" scale="0" precision="4"/>

<property name="PARENTID" nullable="true" type="Edm.Guid"/>

<property name="SORTIERUNG" nullable="true" type="Edm.String" collation="1252LATIN1" unicode="false" maxlength="5"/>

<property name="UEBERSCHRIFT" nullable="false" type="Edm.Boolean"/>

<property name="BEZEICHNUNG" nullable="false" type="Edm.String" collation="1252LATIN1" unicode="false" maxlength="60"/>

<property name="TEXT" nullable="true" type="Edm.String" collation="1252LATIN1" unicode="false" maxlength="2147483647"/>

<property name="CREATOR" nullable="true" type="Edm.String" collation="1252LATIN1" unicode="false" maxlength="80"/>

<property name="CREATED" nullable="true" type="Edm.DateTime" precision="6"/>

<property name="LASTUSER" nullable="true" type="Edm.String" collation="1252LATIN1" unicode="false" maxlength="80"/>

<property name="LASTUPDATE" nullable="true" type="Edm.DateTime" precision="6"/>

<navigationproperty name="ErledigteArbeiten" torole="ErledigteArbeiten_Dependent" fromrole="ErledigteArbeiten_Principal" relationship="Engel.FK_ErledigteArbeiten_ErledigteArbeitenParent"/>

<navigationproperty name="FK_ErledigteArbeiten_ErledigteArbeitenParent" torole="ErledigteArbeiten_Principal" fromrole="ErledigteArbeiten_Dependent" relationship="Engel.FK_ErledigteArbeiten_ErledigteArbeitenParent"/>


-<association name="FK_ErledigteArbeiten_ErledigteArbeitenParent">

<end type="Engel.ErledigteArbeiten" multiplicity="*" role="ErledigteArbeiten_Dependent"/>

-<end type="Engel.ErledigteArbeiten" multiplicity="0..1" role="ErledigteArbeiten_Principal">

<ondelete action="Cascade"/>



-<principal role="ErledigteArbeiten_Principal">

<propertyref name="GUID"/>


-<dependent role="ErledigteArbeiten_Dependent">

<propertyref name="PARENTID"/>




-<entitycontainer name="Engel_Container" m:isdefaultentitycontainer="true">

<entityset name="ErledigteArbeiten" entitytype="Engel.ErledigteArbeiten"/>

-<associationset name="FK_ErledigteArbeiten_ErledigteArbeitenParent" association="Engel.FK_ErledigteArbeiten_ErledigteArbeitenParent">

<end role="ErledigteArbeiten_Dependent" entityset="ErledigteArbeiten"/>

<end role="ErledigteArbeiten_Principal" entityset="ErledigteArbeiten"/>





(07 Oct '14, 12:01) Armin Back
showing 3 of 7 show all flat view

This has been fixed for build 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.

permanent link

answered 23 Oct '14, 19:39

PhilippeBertrand%20_SAP_'s gravatar image

accept rate: 22%

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.

permanent link

answered 07 Oct '14, 13:54

PhilippeBertrand%20_SAP_'s gravatar image

accept rate: 22%

edited 07 Oct '14, 14:31

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 07 Oct '14, 09:25

question was seen: 3,333 times

last updated: 23 Oct '14, 19:39