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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

OData Client Code Generator Error

(0) ShareShare
ReportReport
Posted on by 45

Hi all,

I want to Integration to Dynamics 365 for operations. But when the code generator tool was run, error occurred.

detail error is below. Anyone who has solution about this?

tool: OData v4 Client Code Generator

visual studio 2012

Advance thanks,

*Error Detail

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Error 1 Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.Library.AmbiguousTypeBinding' to type 'Microsoft.OData.Edm.IEdmCollectionType'.
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.Utils.GetClrTypeName(IEdmTypeReference edmTypeReference, Boolean useDataServiceCollection, ODataClientTemplate clientTemplate, CodeGenerationContext context, Boolean addNullableTemplate, Boolean needGlobalPrefix, Boolean isOperationParameter) in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 2790
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.<>c__DisplayClass45.<WritePropertiesForStructuredType>b__42(IEdmProperty property) in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 2228
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.WritePropertiesForStructuredType(IEnumerable`1 properties) in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 2223
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.WriteEntityType(IEdmEntityType entityType, Dictionary`2 boundOperationsMap) in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 1763
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.WriteNamespace(String fullNamespace) in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 1256
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.WriteNamespaces() in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 1203
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.ODataClientTemplate.TransformText() in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 1195
at Microsoft.VisualStudio.TextTemplatingB3E5289CD3F90D44C86E226F85E52DA32ECE1D396C6DE26DDD7A5029CD1D6ADB10857448D61930C057435C5064C838D80C6AE4046801A81B22E0E238232761EA.GeneratedTextTransformation.TransformText() in c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs:line 96 c:\Users\dchung\AppData\Local\Temp\muip0at5.0.cs 2790 1 Miscellaneous Files

------------------------------------------------------------------------------------------------------------------------------------------------------------------

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,286 on at

    Hi daehyun,

    AX returns metadata for all extincting entities, so clients tries to generate classes for all of them in the same time, but there are duplicated types in metadata like ItemType and it fails with AmbiguousTypeBinding exception as you can notice.

    As a workaround you can delete all entities except one you need (and dependencies) and use this striped version of metadat for generation.

  • daehyun Profile Picture
    45 on at

    Hi ievgen Miroshnikov,

    Thank you for your reply. and I have one more question.

    How can I delete entity info? in my source code, I just set the url of metadata.  

    Like this : retail1611pu6c4dd29587c42e289devaos.cloudax.dynamics.com/data$metadata

    Thank you,

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    You can save it as a file and point it to a file

  • kartikkp7 Profile Picture
    365 on at

    Did it resolved you error?

  • daehyun Profile Picture
    45 on at

    Not yet. I deleted entity which is not using. but code generator was failed. I will try to using json and x++.

  • Verified answer
    kartikkp7 Profile Picture
    365 on at

    Hello...

    The actual problem is in metadata. There is an Enum with name "ItemType" and also the Data Entity with same name "ItemType". Due to which the proxy file is not generated due to same name and giving the error.

    The solution will be changing the name of Data Entity "ItemType" to "ItemTypes"

    EntityType Name="ItemTypes"

    and also do not forget to change the name in Entity Set in container.

    EntitySet Name="ItemTypes" EntityType="Microsoft.Dynamics.DataEntities.ItemTypes"

    We have tested the same and it works fine.

  • daehyun Profile Picture
    45 on at

    Hi Kartik,

    Thank you for your Answer. I tried your solution on and I also succeeded. :)

    Thanks,

  • Suggested answer
    Hichem.Chekebkeb Profile Picture
    3,371 on at
  • Andrew Xu Profile Picture
    3,877 on at

    How did you figure out that "ItemType" causes this  problem?

  • Community Member Profile Picture
    on at

    Thank you, worked for me

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans