This is a quick tip on how to create a simple Dynamics CRM console application in C# that connects to Dynamics CRM 2016 and creates an account record. There is some sample code in the SDK that demonstrates how to do this but this sample is even simpler.
static void Main(string[] args) { // Get the CRM connection string and connect to the CRM Organization CrmServiceClient crmConn = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRM"].ConnectionString); IOrganizationService crmService = crmConn.OrganizationServiceProxy; Entity acc = new Entity("account"); acc["name"] = "Joe's New Account"; crmService.Create(acc); }
<connectionStrings> <add name="CRM" connectionString="AuthType=Office365;Url=https://joegilltest.crm4.dynamics.com; Username=joe@joegilltest.onmicrosoft.com; Password=MyPassword" /> </connectionStrings>
using System.Configuration; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Tooling.Connector;