Monday, October 12, 2015

How to Generate Early Bound Entity Classes using CrmSvcUtil.exe(Using Auto Code Generation Tool)

How to Generate Early Bound Entity Classes using CrmSvcUtil.exe(Auto Code Generation Tool):



About the code generation tool


The CrmSvcUtil.exe tool creates a Microsoft Visual C# or Microsoft Visual Basic .NET output file that contains strongly-typed classes for entities in your organization. This includes custom entities and attributes. This output file contains one class for each entity, providing early binding and IntelliSense support in Microsoft Visual Studio to aid you as you write custom code. The generated classes are partial classes that can be extended with custom business logic in separate files. You can also create extensions to this tool. For more information, see Create extensions for the code generation tool.
The tool can also be used to generate a class derived from the OrganizationServiceContext class that acts as an entity container in the entity data model. This service context provides the facilities for tracking changes and managing identities, concurrency, and relationships. This class also exposes a SaveChanges method that writes inserts, updates, and deletes records in Microsoft Dynamics CRM. For more information, see Use the OrganizationServiceContext class.
The code generation tool takes several parameters that determine the contents of the file that is created. The parameters can be passed in from the command line when you run the tool or in a .NET-connected application configuration file.
The classes created by the code generation tool are designed to be built into a class library that can be referenced by projects that use Microsoft Dynamics CRM. After you have generated the class file using the tool, you should add the file to your Visual Studio project. You must also add references to several assemblies that the generated classes are dependent upon.
The following lists assemblies that must be referenced in your project when you use the generated code file.
  • Microsoft.Crm.Sdk.Proxy.dll
  • Microsoft.Xrm.Sdk.dll
These assemblies can be found in the The SDK\Bin folder of the SDK. Download the Microsoft Dynamics CRM SDK package.

To Run the code generation tool:

  • For Online CRM:
           1> Open Command Prompt in your Windows PC

           2>Find CrmSvcUtil.exe at SDK which is located at (SDK/Bin Folder)

           Example:

   Click Enter, Then

    

   Now we are in correct path..

   3> CrmSvcUtil.exe /url:https://<organizationUrlName>.api.crm.dynamics.com/XRMServices/2011/Organization.svc /out:<outputFilename>.cs /username:<username> /password:<password> /namespace:<outputNamespace> /serviceContextName:<serviceContextName>

The following sample shows the format for running the tool from the command line with Microsoft Dynamics CRM Online. 

You supply the parameter values appropriate for your account and server.

You need to supply 1.OrganizationUrlName(This should be exact and mandatory)

                                  2.OutputFileName(User Choice)

                                  3.username(This should be exact and mandatory)          

                                  4.password(This should be exact and mandatory)

                                  5.serviceContextName(User choice)

     Example:

     Hit Enter key to Generate Xrm.cs File.

  • For On-Premeses CRM

    1> Follow 2 steps same as Online - CRM 

    2> CrmSvcUtil.exe /url:http://<serverName>/<organizationName>/XRMServices/2011/Organization.svc /out:<outputFilename>.cs /username:<username> /password:<password> /domain:<domainName> /namespace:<outputNamespace> /serviceContextName:<serviceContextName>

The following sample shows the format for running the tool from the command line for an on-premises installation of Microsoft Dynamics CRM.

 You supply the parameter values for your installation.

1.You need to Supply:1.serverName(Should be exact :Must add port number,Ex: server2015:6666)

                                     2.OrganizationName(Find at CRM->Settings->DeveloperResources->OrgName)

                                     3.OutputFilename(User Choice)

                                     4.username(Should be exact)

                                     5.password(Should be exact)

                                     6.domainName(Should be exact)

                                     7.outputNameSpace(User Choice)

                                     8.serviceContextName(User Choice)

Example:

   Hit Enter to Generate Xrm.cs file.

   Thank You.....

  


    

No comments:

Post a Comment