4
votes

I have successfully generated the OData client code using this generator to access my Dynamics CRM WebApi services. Unfortunately for a vanilla organisation it generated a ~30 MB cs file. This is way to large as all I need is to access a few entities.

I know I can download the metadata for the OData service and manually edit before running the generator but I am looking for a more developer friendly way.

I have looked for a way to limit the metadata directly but it seems the xml metadata file is static: Fetching $metadata for a specific collection or entity with Odata web services in Microsoft Dynamics NAV 2016

What is the best way to generate proxy classes just for some entities?

EDIT: I actually tried to manually edit the metadata file by removing EntityType nodes and respective EntitySets but the tool complained about some interface IEdm... so still unsolved.

1
If you are talking about Svcutil, someone has a solution here erikpool.blogspot.co.uk/2011/03/…James Wood
@JamesWood No, not CrmSvcUtil, I have added a link to client code generator recommended for WebApi services.Valentin
Did you find a solution to this?F.H.
@F.H. No, haven't had time to look into it. At the moment I am accessing the OData service with a simpler library (no proxy classes auto-generated, manually constructing url; only helping me in parsing response).Valentin

1 Answers

1
votes

I believe the recommended way to prevent data entities from being exposed through the ODATA layer is to set the "Public" property to false on the entity in Dynamics 365.

I am running into exactly the same issue; having the TT proxy file auto generated with the OData Client Generator in VS 2012 which results in a 50Mb class. This renders Visual Studio extremely unstable crashing most of the times.

Since there are over 2000 entities in D365 it's basically impossible to set them all to private this way, since we couldn't find a way to select multiple entities and update them all at the same time.

If anyone has a direct SQL update or another way to achieve this, I'd like to hear too.