Notifications
Announcements
No record found.
Hi,
I have created OdataUtility to connect with D365FO.
I have installed Odata client Generator V4 and added OdataClient.tt file and set metadataDocumentUri to appropriate URL.
now it generated OdataClient.cs but when i try to build the solution, it throws below error. Please help if you know how to fix it. Thanks.
~ Vikky
Could you check the code lines where the errors come from? And also share your code with us?
Hi Vikky,
Try replacing the "LoadModelFromString" method in OdataClient.cs with this code -
private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString() { global::System.Xml.XmlReader reader = CreateXmlReader(Edmx); try { return global::Microsoft.OData.Edm.Csdl.EdmxReader.Parse(reader); } finally { ((global::System.IDisposable)(reader)).Dispose(); } }
Are you using demo project https://github.com/microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples/ODataUtility ?
I recommend you not to use oDataUtility as it looks outdated, but create a new connected service with the latest version of oData generator + update oData.Client library to the latest version.
www.atomicax.com/.../part-1-getting-connected-vs2017-and-connected-services
Hi Nikolaos,
It fails at below line
return global::System.Xml.XmlReader.Create(new global::System.IO.StringReader(edmxToParse));
Hi Gunjan,
Thanks for your reply, but what is the 'Edmx' variable? Also, it fails at my end saying Microsoft.odata.Edm.csdl not found in the assembly. Are you missing a reference?
What version of Odata are you using? Please Try CsdlReader. This solution was provided by MS last time we had this issue. Please try this and check if you can compile successfully
private static global::Microsoft.OData.Edm.IEdmModel LoadModelFromString() { global::System.Xml.XmlReader reader = CreateXmlReader(Edmx); try { return global::Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader); } finally { ((global::System.IDisposable)(reader)).Dispose(); } }
Manual fixing of auto-generated file OdataClient.cs will not help you too much in this case as next time when you refresh metadata you will get the same issue as all your manual changes wwill be wiped from the file.
There are different T4 templates are used for older and newer oData generator versions to generate .net code in OdataClient.cs. If you want to have a permanent fix you need to re-add the connected service or fix the T4 template (oDataClient.ttinclude).
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 663 Most Valuable Professional
André Arnaud de Cal... 540 Super User 2025 Season 2
Sohaib Cheema 348 User Group Leader