Solution Packages allow you to deploy multiple solutions alongside configuration data is an executable using the Package Deployer. The Configuration Migration tool is included in the Dynamics 365 SDK, and is Microsoft’s approach to maintaining configuration data in solution deployments. The benefits include;
- Provides the ability to export complex data structures and dependencies which would be difficult with csv files·Can be executed as a step within solution package deployments
- Create and Update existing records, whilst maintaining guids across deployments
- Option to define multiple lookup keys on import allowing to update records with duplicate values
- Option to disable plugin steps during data import
- Option to overwrite timestamp of imported data
- Data Migration performs checks against the schema on import, and so does not skip the import whilst Package Deployer is running which csv files have a tendency to do.
- Schema file can be easily reused to generate updated zip
The Configuration Migration tool is included in the Dynamics 365 Nuget package which can be downloaded locally and includes the following;
Tool |
NuGet Package |
Code generation tool CrmSvcUtil.exe |
|
Configuration Migration tool DataMigrationUtility.exe |
Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf |
Package Deployer PackageDeployer.exe |
Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF |
Plug-in Registration Tool PluginRegistration.exe |
Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool |
SolutionPackager tool SolutionPackager.exe |
Microsoft.CrmSdk.XrmTooling.SolutionPackager |
Step-by-step guide
1) Download instructions for Dynamics 365 SDK Tools: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/download-tools-nuget
2) Running the Configuration Migration Tool C:\Tools\ConfigurationMigration and run the DataMigrationUtility.exe
3) Create Schema
4) Connect to Golden Source of Data Instance ie Master Dev
5) Select Solution, Entities and Attributes;
6) Add Entities, attributes for Configuration Data
7) Configure Additional Import Settings;
Additional Options for Updating records can be defined in Configure Import Settings, this only needs to be used if you want to provide additional criteria for updating duplicate value rather than just updating based on the guid or disabling a plugin whilst data is being imported.
Select Timestamp criteria, allows to define whether you want to keep the Source Timestamps or update on create on the Target.
8) Save Scheme File: The Schema file is an XML Schema file that can be reused for future data exports
9) Export Data: Once your Schema File is saved you will be prompted to export the data based on the defined schema;
10) Copy Zip to Project Folder
Now that you have your Data Configuration Zip file you can check it in to your solution, the Data.zip file should be placed into the following location;
C:\Users\choudryr\Source\Repos\SMART-CXP-DEV\TFGM.D365.smartCXP\DeploymentPackage\PkgFolder
This can be achieved by performing the following steps;
Right Click PkgFolder and Add existing item;
11) Select the zip file you exported earlier which will place the file into the Solution
Once the zip file appears in the PkgFolder in your Projects Solution, Update its Properties of ‘Copy to Output Directory’ as ‘Copy Always.
12) Finally update the ImportConfig.XML with the value for crmmigdataimportfile="data.zip"
Now when you build your solution the Solution Packager will include your Configuration Data, please remember to comment out the Filestoimport tags as this is no longer required.
Considerations;
The Configuration Migration data file will not delete data, only create and update, so one approach can be to run a bulk delete job on the config entities before every build and release. Also this tool does not allot to filter the records within an entity so it will always migrate all the records. Its also worth nothing that the Root Business unit Guid is always different in each environment and cannot be overwritten so yo will have to append the XML for the root business unit to use the Root business unit reference guid of the target environment to successfully deploy your business unit relationships.
The alternative approach is to use CSVs files which allows you to filter the records and be selective on the records to be imported as well as maintain original guids across environments which you can read about in by next article!
*This post is locked for comments