Search code examples
dynamics-crm

Migrating Sql Records into Crm entity


I'm new to Microsoft dynamics 365 CRM.

I have SQL Table Called Account, and I need to Create C# Console application in Visual Studio that Inserts my SQl Account records into CRM Account Entity through SDK.

I'm very confused about how to do it any clue?

Thank you


Solution

  • If you are just trying to import data into Dynamics365 as part of a one time data migration then I would recommend using the built in import engine to import a CSV created from that source table. If the engine doesn't meet your needs or you are looking to add custom logic that the import engine doesn't support then you would want to use the XRM Tooling Connector Nuget Package

    Once you've added that Nuget Package you can create a CrmServiceClient and use that to interact with CRM using roughly the same api that you would be using to create plugins and custom workflow steps.

    CrmServiceClient service = new CrmServiceClient("<connection-string-here>");
    // Now you can use it to create a contact
    Entity contact = new Entity("contact");
    contact["fullname"] = "Contact Name";
    service.Create(contact);
    

    Since you said you're new here is what a connection string for Dynamics365 looks like

    "AuthType=Office365; url=<insert-the-url-to-dynamics-365>; username=<your-username>; password=<your-password>;"