using CrmSvcUtil


Use CrmSvcUtil to generate the strongly types entity and datacontext classes

crmsvcutil

/connectionString:"Authentication Type=Integrated; Server=http://servername/orgname"

/out:"Xrm.cs" /namespace:"Xrm.solution"

/dataContextClassName:"xrm"

conntectionString–> specifies the connection string.
out –> determines the name of the .cs or .xml output file and whether there is one file or one per entity.To generate one file per entity omit .cs or .xml from the file name.
namespace –> to specify the namespace
dataContextClassName –> to specify the name of the dataContext class.

Add references to the following dlls in the project

  • System.Data.Entity, System.Data.Services, System.Data.Services.Client.
  • System.Web.Services.
  • Microsoft.Crm.Sdk, Microsoft.Crm.SdkTypeProxy.dll, Microsoft.Crm.SdkTypeProxy.XmlSerializers
  • Microsoft.Xrm.Client, Microsoft.Xrm.Portal, Microsoft.Xrm.Portal.Files

Add the generated Xrm.cs file to the project.

Add the connection string information in the config file of the application

<add name="CRMOnPremise" connectionString="Authentication Type=Integrated; Server=http://servername/orgname" />

Add following using Statements

using Xrm;
using Xrm.solution;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;

And the code for creating a new custom entity record.

            new_test testEntity1 = new new_test();
            testEntity1.new_name = "Nishant";
            testEntity1.new_lastname = "Rana";
            myXrm.AddTonew_tests(testEntity);
            myXrm.SaveChanges();

 

or could also be written as

            // create the instace of DataContext class named xrm
            var myXrm = new xrm("CRMOnPremise");
          
// use concept of Implicitly type local variable 
           
// and object intializer
            var testEntity = new new_test()
            {
                new_name = "Nishant",
                new_lastname = "Rana"
            };
            myXrm.AddTonew_tests(testEntity);
            myXrm.SaveChanges();

 
 

Similarly to update a record and delete a record we need to use

UpdateObject() and DeleteObject() function followed by call to

SaveChanges() method.

Bye.


Discover more from Nishant Rana's Weblog

Subscribe to get the latest posts sent to your email.

Unknown's avatar

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

3 thoughts on “using CrmSvcUtil”

  1. Very nice the way that you use the tool.
    But I have a problem: I generated a form tool to make easier the way to generate classes, but when I pass all the arguments that the tool needs, the console window gets freeze. I do not know what kind of security requeriments crmsrvcutil is using.
    But we are working in an envorioment in wich we need to generate custom entities very often. We like the tool, but what we do not like is to write a long argument string to generate our entity’s classes.

    Excuseme if my english is not good
    Greetings

    Like

  2. So when we use the CrmSvcUtil we can get all the system and custom entities of the organization at that time.Now when any new custom entities are added we will required to generate the Class file using the CrmSvcUtil , is it right ?

    Like

Leave a reply to Xitij Thool Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Nishant Rana's Weblog

Subscribe now to keep reading and get access to the full archive.

Continue reading

Power Platform Puzzles

D365 CRM, Power Platform Tips &Tricks

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Microsoft Business Applications Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog - PPUG.ORG

AI - Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue

The Professional Paraphraser

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

Power Platform Learning

Your Go-To Resource for Power Apps, Power Automate & More

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.