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

OData Client Generation VS2022

(0) ShareShare
ReportReport
Posted on by 555

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
    25 Moderator on at

    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
    239,040 Most Valuable Professional on at

    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
    555 on at

    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
    555 on at

    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
    555 on at

    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
    555 on at

    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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans