Tuesday, February 7, 2012

Early Bound – generate Entity class

Early Bound – generate Entity class

CRM 3, 4 and now in 2011 have 2 options to work with attributers.

Strong type (early bound) and Late bound Dynamic Entity\Entity)

The different code between two options:

If you need to work for CRM online strong type not good for you because plugin issues.

Nice to work strong type and maybe faster but I prefer Entity

1 strong type example:

Contact c= new contact

c.firstname = “rami;

 2. late bound (dynamic entity was for CRM 3, 4):

Entity c= new Entity (“contact”);

C[“firstname”]= “rami”;…..

To generate data.cs file with metadata attributes need to use file:crmsvcutil.exe

Crmsvcutil.exe must reference the next files:

1.       Microsoft.xrm.client.codegeneration.dll

2.       Microsoft.xrm.client.dll

3.       Microsoft.xml.sdk.dll

Create Bat file CreateMetadata.bat and set inside the next command:


CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:OutputfileName/url:http://Server/organizationName/XRMServices/2011/Organization.svc /domain:DomainName/username:UserName/password:password/namespace:Xrm /serviceContextName:XrmServiceContext


CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Xrm.cs /url:http://crm2011/CRM/XRMServices/2011/Organization.svc /domain:CONTOSO /username:administrator /password:pass@word1 /namespace:Xrm /serviceContextName:XrmServiceContext

After run the batch file get file Xrm.cs.

Now u can use this file in your code. (Don’t forget to generate after change the entities.

Rami Heleg

No comments:

Post a Comment

Post a Comment