1
votes

I used to generate early bound classes for Dynamics CRM using CrmSvcUtil and the 2011 endpoint.
This still works but is due to be deprecated so I'm trying to understand the new OData endpoint and use this to generate the classes.

You can view the entity model XML for CRM by browsing to the appropriate URL:

https://myorg.crm4.dynamics.com/api/data/v8.1/$metadata

Or alternatively you can just download the XML from the developer section in CRM:

download odata metadata

In either case you end up with the XML defining the entity model:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
  <edmx:Reference Uri="http://vocabularies.odata.org/OData.Community.Keys.V1.xml">
    <edmx:Include Namespace="OData.Community.Keys.V1" Alias="Keys" />
    <edmx:IncludeAnnotations TermNamespace="OData.Community.Keys.V1" />
  </edmx:Reference>
  <edmx:Reference Uri="http://vocabularies.odata.org/OData.Community.Display.V1.xml">
    <edmx:Include Namespace="OData.Community.Display.V1" Alias="Display" />
    <edmx:IncludeAnnotations TermNamespace="OData.Community.Display.V1" />
  </edmx:Reference>
  .... blah blah ....

How do I convert this to a set of strongly typed C# classes?

I found this guide which recommends using the OData v4 Client Code Generator tool but this seems like overkill and I'd rather avoid using tools that may cease to work in the future.

I also saw the MSDN article for DataSvcUtil.exe which can convert EDMX files but I have an XML. I tried changing the file extension but it won't convert, it throws an error:

error 7001: The 'Scale' attribute is invalid - The value 'Variable' is invalid according to its datatype 'http://schemas.microsoft.com/ado/2007/05/edm:TScaleFacet' - The string 'Variable' is not a valid Integer value.
The string 'Variable' is not a valid Integer value.

I'm now stuck and not sure which is the recommended way to do this.

1

1 Answers

1
votes

Microsoft has stated that they will transition the SDK from the 2011 endpoint to the WebAPI. I haven't heard any details with what that means for early bound types, but I'm guessing they will come out with an official response before then. (maybe a CrmWebApiUtil.exe) I believe the CrmSrvUtil was originally written by a third party, and Microsoft just took ownership of it.