How to avoid System.InvalidCastException: Unable to cast object of type 'Microsoft.OData.Edm.Library.AmbiguousTypeBinding' to type 'Microsoft.OData.Edm.IEdmCollectionType'.
Views (3032)
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:
- Run the metadata link in a navigator : https://********.ax.dynamics.com/data/$metadata
- Wait until it finishes extracting, save it as xml file
- 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.
*This post is locked for comments