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

Community site session details

Session Id :

How to avoid System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.Library.AmbiguousTypeBinding' to type 'Microsoft.OData.Edm.IEdmCollectionType'.

Hichem.Chekebkeb Profile Picture Hichem.Chekebkeb 3,371

Problem:

When trying to extract metadata using Odata client you will get this error System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.Library.AmbiguousTypeBinding' to type 'Microsoft.OData.Edm.IEdmCollectionType'.

Solution:

  1. Run the metadata link in a navigator : https://********.ax.dynamics.com/data/$metadata
  2. Wait until it finishes extracting, save it as xml file
  3. Use that file to generate the POCOs like : public const string MetadataDocumentUri = "File:///D:/metadata.xml";

Once you save the file the client will generate the metadata classes much faster and without the highlighted issue.

Comments

*This post is locked for comments