Step by step: Using CrmSvcUtil.exe in on-premise Active Directory typical scenario
I am developing some new Dynamics CRM pluggins and decided to use the latest release up-to-date of the Dynamics CRM SDK which was released a couple of days ago :).
My scenario: CRM 4.0, on-premise, Active Directory (AD) Authentication typical scenario.
So, I decided to share the steps to run the CrmSvcUtil.exe command to generate the data context and data transfer object classes for using LINQ in the above scenario , so you can copy-paste the parameters as reference in a similar one.
Besides, as the command failed until I run it with elevation (Administrative privileges), I also wanted to point this out to avoid headaches to somebody else.
So, here are the steps to generate the classes using the CrmSvcUtil.exe tool for an on-premise AD scenario:
1. Open command prompt with elevation. In my case, crmsvcutil tool stopped running and after running inside a command prompt with elevation, it worked like a charm.
So, lets open the command prompt this way:
2. Within command prompt window, go to [sdk\microsoft.xrm\tools] directory
For instance:
CD C:\.....\sdk\microsoft.xrm\tools
3. Once there, write the crmsvcutil command with the corresponding parameters. I recommend you use a text editor (i.e. just notepad) to adjust the parameters and then copy-paste the full statement in the command prompt.
In the case of an standard on-premise, Active Directory authentication scenario, the statement syntax is:
crmsvcutil /connectionString="Authentication Type=AD;Server=http://{mycrmserver}:{mycrmserverport}/{myorganizationname};User ID={domain}\{username};Password={password}" /namespace:{MyOrganizationName}.Xrm /dataContextPrefix:{MyOrganizationName} /out:{MyOrganizationName}.Xrm.cs
For instance, take the following statement for 'Contoso' organization on 'crm' server:
crmsvcutil /connectionString="Authentication Type=AD;Server=http://crm:5555/Contoso;User ID=contosodomain\crmadmin;Password=Password01" /namespace:Contoso.Xrm /dataContextPrefix:Contoso /out:Contoso.Xrm.csThere are other parameters that can be specified, but this should be enough for the majority of the scenarios. For more info, see this.
4. After pressing Enter, the command starts to run (it takes some seconds) and when successfully finished it says that the classes were written to … (your output directory and file name)
So, what did CrmSvcUtil.exe generated? It generated:
· statically typed entity classes
· many-to-many relationship classes
· enumeration types for Picklist values
· class names and property names based on Microsoft Dynamics CRM display names, which are more readable than the schema names
· a WCF Data Services (Astoria/oData) compatible data context class for managing entities
For more info on CrmSvcUtil.exe capabilities click here.
Hope it helps to save somebody else some time.
PP