web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

OData Client Code Generator Issue

(0) ShareShare
ReportReport
Posted on by 25

Hi All,

Getting the below error while getting the OData code after entering the URL and hit save in "tt" file.

URL is public const string MetadataDocumentUri = "xxx.sandbox.ax.dynamics.com/data$metadata";

VS: 2017

Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.AmbiguousTypeBinding' to type 'Microsoft.OData.Edm.IEdmCollectionType'.

One of the forum https://community.dynamics.com/ax/f/33/t/266164 given that use try catch block at some place and need to change the ItemType DataEntity name. But after doing this change also getting DataEntities already contains "ItemType". So to avoid this, made a change in Enum name from "ItemType" to "ItemTypeE", and commented the other lines where error is throwing. Now no errors found but doing these changes again and again takes 3 to 4 hours as VS is restarting automatically because of huge size of ODataClient.cs file. I am doing this class generator again because to update Data Entities.

Is there any way that I can reduce this change in VS without hang more time?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Hichem.Chekebkeb Profile Picture
    3,371 on at
  • PRSCOL Profile Picture
    25 on at

    @Hichem,

    Thanks for your comment. I followed your steps. This is useful to speed up the metadata generation. But still the original issue with "InvalidCastException" exists. So do you have resolution for this?

  • Suggested answer
    Sai Krishna N Profile Picture
    15 on at

    Hi, The issue is with the Metadata. It has and Entity with name "ItemType" also a property with name "ItemType", in order to resolve the issue you were getting you need to download the metadata from a browser and save it as XML. Then edit the XML file you have downloaded and find for the following line

    EntityType Name="ItemType" and change it to "EntityType Name="ItemTypes" also search for the following EntitySet Name="ItemTypes" and change it to EntitySet Name="ItemTypes" EntityType="Microsoft.Dynamics.DataEntities.ItemTypes".

    This worked for me. Hope this will help you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans