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 :
Finance | Project Operations, Human Resources, ...
Answered

OData Client Generation VS2022

(0) ShareShare
ReportReport
Posted on by 545

Hi,

I used to use the OData Client Generation tool in the past with the odata.tt file.

One thing I didn't like about it was that it generated a client for all the entities, a massive 90mb file.  Has anyone found a way around this to create only the entities that they need? (like in Dynamics CRM?)

Another thing - we are not in mid 2022, and VS2022 is the new norm - is there an odata client generation tool that works for VS2022?  I've tried a few but they don't seem to do the job.

Thanks,

Norbert

I have the same question (0)
  • Verified answer
    nunomaia Profile Picture
    23 Moderator on at
    RE: OData Client Generation VS2022

    You can use OData CLI version. 

    https://docs.microsoft.com/en-us/odata/odatacli/getting-started 

    Try to split generated code in multiple classes and only deploy required ones  

  • Verified answer
    Martin Dráb Profile Picture
    236,279 Most Valuable Professional on at
    RE: OData Client Generation VS2022

    You can also use tools like EDMXTrimmer.

    Regarding VS 2022, have you tried ODataConnectedService? I haven't, but it's the first thing that I would try.

  • nspiteri Profile Picture
    545 on at
    RE: OData Client Generation VS2022

    Thanks,

    I'll check out the trimmer.  I've tried the Unchase OData Connected Service (marketplace.visualstudio.com/items

    (github.com/.../)

    Had mixed feelings about it because it forced me to get all the entities which made vs2022 and my class library very cumbersome.  I'll take a look at the options you suggested and write back.

    I happened upon this by accident as I rarely use the odata clients - I prefer to use httpclient directly, but it would be nice if there was an official, updated guideline from Microsoft on how to do it.

  • nspiteri Profile Picture
    545 on at
    RE: OData Client Generation VS2022

    small update about Unchase is that the resulting connected service reference causes compile errors - due to the fact that it is bulky and has error, I'll stop looking into it.

    edit: the same error i.e. " 'string' does not contain a definition for 'EntityTracker' and no accessible extension method 'EntityTracker'" also occurs if I used the Odata Cli tool so its not a fault of UnChase.

    I saw some community posts dated July 2022 about this error that are still unsolved so I'll dig into it

    For this part I still have no solution however with the EDMX Trimmer, I managed to generate a Connected Service that works

  • nspiteri Profile Picture
    545 on at
    RE: OData Client Generation VS2022

    also the Odata Connected Service does not work with VS2022 - it doesn't show up on the marketplace and trying to install it manually via the vsix says "this extension is not installable on any currently installed products".  It appears to be a front end for the cli anyway - so I'll go that way next

  • nspiteri Profile Picture
    545 on at
    RE: OData Client Generation VS2022

    ok, so I got it to work with a mix of solutions - however only on .net Framework 4.7 because on .net core I'm getting authentication issues which are not part of this topic.  Here is what I did:

    1. I downloaded the whole meta data file locally i.e. the /data/$metadata with an extension .edmx
    2. I git cloned the EdmxTrimmer and used the following to trim the metadata into one that only has SalesOrderLines:

    dotnet EDMXTrimmer.dll --edmxfile metadata.edmx --entitiestokeep SalesOrderLines

    (its important to specify entitiestokeep otherwise it will not keep any entities at all) - also note that the casing of the entitiestokeep is different from that described on the github repo).  The resulting file was c.2Mb in size as compared to > 36Mb from the original

    3. I use the Unchase OData Connected Service and pointed it to the edmx file I had just created.  You'll need to type the edmx file path manually because Unchase only sees xml files.  In Advanced Settings you also have to Enable entity and property tracking

    It all works fine, even tested it with OData batch mode.

    Thank you all for your help

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,177

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 860 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 593 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans