Register product
You receive the secret-key with the demo license or by e-mail after an official order
DataMigratePro --registration <secret-key> --tenantid <TenantID>Define interfaces
Both the SQL Server database and the Business Central instance have to be made known to the program for further work.
To enable a data transfer, a so-called app resource must be created, configured in Business Central and given the corresponding permissions. Further details are provided in the documentation How to Register Business Central App with API Permissions in Azure Portal – NAVUSER
DataMigratePro /
--sqlconnection "Data Source=localhost;Initial Catalog=Demo Database NAV (6-0);Integrated Security=SSPI;" /
-w "https://api.businesscentral.dynamics.com/v2.0/<TenantID>/<Environment>/ODataV4/Upload_LoadData?company=<Company>" /
--tenantid <TenantID> --clientid <ClientID> /
--clientsecret <Client Secret> /
--sourcecompany <Source Company> /
--mappingdatabase <Mappin
--destinationcompany <Destination Company>After the interfaces have been defined with the command above, DataMigratePro has created the file settings.json.
{
"SqlConnectionString": "Data Source=localhost;Initial Catalog=Demo Database NAV (6-0);Integrated Security=SSPI;",
"SourceDatabase": "Demo Database NAV (6-0)",
"SourceCompany": "<Source Company>",
"DestinationCompany": "<Destination Company>",
"TenantInfo": {
"TenantId": "<TenantID>",
"ClientId": "<ClientID>",
"ClientSecret": "<Client Secret>"
},
"BlobMagicSignature": [ 2, 69, 125, 91 ],
"EndpointUrl": "https://api.businesscentral.dynamics.com/v2.0/<TenantID>/<Environment>/ODataV4/Upload_LoadData?company=<Company>",
"MappingDatabase": "Migration"
}Transfer of the mapping configuration
The following command transfers the mapping configurations from the source system to the target system
DataMigratePro -t saveconfigurationThe following command transfers the mapping configurations from the target system to the source system
DataMigratePro -t loadconfigurationTransfer of all master and setup data
Once the Navision database has been extended with the configuration tables, the first transfer can be started.
DataMigratePro -t putalldata --automappingThe switch putalldata sends all table contents whose category is master data or setup to Business Central.
Transfer of all posted documents and entries
With putalldata, the data in the target table is deleted before the data is transferred even if the option Delete before Transfer has been set in the configuration for the respective table.
DataMigratePro -t putalldata --tablegroup "3,4" --automappingTransfer of changed data
If the change log is active for tables in Navision, the following command sends only the changes to Business Central.
DataMigratePro -t putalldata --changesonly 1 --automappingTransfer of individual tables
If data is to be generated from your own queries and sent to Business Central, a mapping file must be created beforehand in addition to the actual command. Here is the command first.
DataMigratePro -t putdata -s 50149 -i "SELECT Feld1,Feld2 FROM Datenbank.dbo.MeineTabelle" -m mappingMeineTabelle.mapping.jsonA matching mapping file could then look like this:
{
"MeineTabelle": [
{
"FieldNo": 1,
"FieldName": "Feld 1",
"MappedName": "Feld1",
"Validate": false
},
{
"FieldNo": 2,
"FieldName": "Feld 2",
"MappedName": "Feld2",
"Validate": false,
"Format": "yyyy-MM-ddTHH:mm:ss"
}
],
"ValidateOnInsert": false,
"ValidateOnModify": false,
"ValidateOnDelete": false
}Receiving data
If you want to determine what was last sent to Business Central, you first have to query this information with a command:
DataMigratePro -t getdata -s 50005 -n "BC Table Statistics" -m mapping/TableStatistics.mapping.jsonYou can likewise read the current structure of the tables in Business Central into the configuration database
DataMigratePro -t getdata -s 2000000058 -v "WHERE(Field1=1(1))" -n "BC Table" -m mappingAllObjWithCaption.mapping.jsonDataMigratePro -t getdata -s 2000000041 -n "BC Field" -m mappingField.mapping.jsonThe first command loads all available tables, while the second reads out the associated fields. The corresponding tables BC Table and BC Field are updated afterwards.
Deleting data in Business Central
Complete content or a filtered set of records can be deleted with deletedata. In the following command, the record of the Payment Terms table with the primary key LM is deleted.
DataMigratePro -t deletedata -s 3 -v "WHERE(Field1=1(LM)"Running codeunits
The following command runs codeunit 50001.
DataMigratePro -t execute -s 50001Running DataMigratePro as a service
You can either run DataMigratePro as a permanent background service by installing it as a service.
sc create DataMigrateProService binPath= ""C:\path\to\DataMigratePro.exe" --service 8000" start= autoOr you can initiate this temporarily on the command line
DataMigratePro --service 8000The port number can be chosen freely. When you call the function SendDataToBusinessCentral in the supplied codeunit BC Migration Manager with RecordRef as the only parameter, exactly this record is sent to Business Central immediately, but asynchronously. Beforehand, the local configuration in Navision specified the PC name and the port on which this service runs.
Import of images and files into Business Central (not yet implemented)
The parameter -t importimages allows a directory structure to be read in automatically and files to be uploaded into the Business Central system. These files are assigned to a Media or Mediaset field of a specific table. After the import, the field in question contains a GUID that references the Tenant Media table, in which the actual files are stored.
Command syntax:
DataMigratePro -t importimages -s <TableNo> --field <FieldName> --sourcepath "<path to directory structure>"Parameter description:
- -s <TableNo>: Specifies the target table in Business Central into which the images are imported.
- --field <FieldName>: Specifies the target field in the table that is configured as Media or Mediaset.
- --sourcepath "<path to the directory structure>": specifies the source directory with the files to be imported.
How it works:
- Scan directory: The specified source directory is searched recursively in order to identify all supported file types. The respective directory name determines the primary key of the target table.
- Upload files: every file is uploaded as a blob into the Tenant Media table. A new GUID is created for the file in the process.
- Link to the target table: the generated GUID is entered in the specified media or media set field of the target table.
- Storage in a tenant media set: if a media set is used, the uploaded files are linked to a tenant media set.
Example:
DataMigratePro -t importimages -s 50000 --field "Produktbild" --sourcepath "C:\Produktbilder"- This command imports all images from C:\Produktbilder into the media field Produktbild of table 50000 (e.g. items).
- The images are stored in Tenant Media, and after the import the field values in the item table contain the corresponding GUIDs.
Requirements:
- The target table must contain a Media or Mediaset field.
- The Business Central instance must be configured for the use of media/mediaset fields.
Supported file formats:
- Images: jpg, png, gif, bmp, tiff
- Documents: pdf, txt, docx
