Migration Steps: Migrate Dynamics NAV 2017 to Dynamics 365 Business Central On-Premise

Hi D365 lovers,

In this article, I am sharing the script that will help you while you are trying to migrate from Dynamics NAV 2017 to Dynamics 365 Business Central On-Premise.
Two steps a developer have to follow during migration. First step is to Upgrade Application Code and after this Data Upgrade.

First create 4 folders in C:\Upgrade folder
* MODIFIED
* ORIGINAL
* TARGET
* RESULT

-------------------- Application Code Upgrade ---------------------------

Original Version: Demo DB 2017
Export-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "Demo Database NAV (10-0)" –Path C:\Upgrade\ORIGINAL\OldBaseVersion.txt -Filter 'Id=1..1999999999'

Modified Version: Demo DB 2017 with Custom Changes
Export-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "Demo Database NAV (10-0)" –Path C:\Upgrade\MODIFIED\OldCUSTOMVersion.txt -Filter 'Id=1..1999999999'

Target Version: Business
Export-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "Demo Database NAV (13-0)" –Path C:\Upgrade\Target\NewBaseVersion.txt -Filter 'Id=1..1999999999'


Merge All versions objects:
Merge-NAVApplicationObject -OriginalPath C:\Upgrade\ORIGINAL -TargetPath C:\Upgrade\TARGET -ModifiedPath C:\Upgrade\MODIFIED -ResultPath C:\Upgrade\RESULT

Join:
Join-NAVApplicationObjectFile –Source C:\Upgrade\RESULT\*.txt -Destination C:\Upgrade\all-merged.txt

Import:
Import-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "UpgradedDB" –Path C:\Upgrade\all-merged.txt

Open Dynamics 365 Business Central Development Environment:
* Sync. Schema For All Tables => With Validation
* Build Server Application Objects
* Resolve issues on different Objects

-- Issue-1: Other Issue after this:
---------------------------
Microsoft Dynamics 365 Business Central
---------------------------
The system is not accessible, because it requires a schema synchronisation.
---------------------------
OK
---------------------------

* Solution -> Select all tables -> Sync. Schema For All Tables => With Validation

-- Issue-2:
---------------------------
Microsoft Dynamics 365 Business Central
---------------------------
There is no company in the database. Contact your system administrator.
---------------------------
OK
---------------------------

* Solution -> Create a company in the database using following script: Run in Business Central Administrator Shell
--> example: New-NAVCompany -ServerInstance UpgradedDBMigration -Tenant CRONUS -CompanyName 'CRONUS Subsidiary'
New-NAVCompany -ServerInstance UpgradedDBMigration -CompanyName 'Upgraded Company'

Wallah! Migration Done................

/* --- Other important Scripts
Split-NAVApplicationObjectFile -Source C:\Upgrade\ORIGINAL\OldBaseVersion.txt -Destination C:\Upgrade\ORIGINAL\Solution\TXT\ -PreserveFormatting

Merge-NAVApplicationObject -OriginalPath C:\Upgrade\ORIGINAL -TargetPath C:\Upgrade\TARGET -ModifiedPath C:\Upgrade\MODIFIED -ResultPath C:\Upgrade\RESULT

Set-NAVApplication -ServerInstance UpgradedDBMigration -ApplicationFamily 'NA'
New-NAVCompany -ServerInstance UpgradedDBMigration -Tenant CRONUS -CompanyName 'CRONUS Subsidiary'
*/


/* --- Check Compatibility for Database
select compatibility_level from sys.databases where name = 'Demo Database NAV (10-0)'
select compatibility_level from sys.databases where name = 'Demo Database NAV (13-0)'
select compatibility_level from sys.databases where name = 'UpgradedDB'
*/

 

-------------------- Data Upgrade ---------------------------
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/upgrade/upgrading-the-data
* Path where you can backup your db: "C:\Program Files\Microsoft SQL Server\MSSQL13.NAVDEMO\MSSQL\Backup"

Task 1: Create full SQL backup of old database

Task 2: Uninstall all extensions in old database
-- Get a list of the extensions that are installed:
Get-NAVAppInfo -ServerInstance <ServerInstanceName> -Tenant default
e.g.: Get-NAVAppInfo -ServerInstance "DynamicsNAV100" -Tenant default

-- For uninstall Each Extension use following command:
Uninstall-NAVApp -ServerInstance <ServerInstanceName> -Name <Name> -Version <N.N.N.N>
e.g.: Uninstall-NAVApp -ServerInstance "DynamicsNAV100" -Name "Envestnet Yodlee Bank Feeds" -Version "1.0.0.0"

-- To uninstall all extensions at once
Get-NAVAppInfo -ServerInstance <ServerInstanceName> -Tenant default | % { Uninstall-NAVApp -ServerInstance <ServerInstanceName> -Name $_.Name -Version $_.Version }
e.g.: Get-NAVAppInfo -ServerInstance "DynamicsNAV100" -Tenant default | % { Uninstall-NAVApp -ServerInstance "DynamicsNAV100" -Name $_.Name -Version $_.Version }

Task 3: Upload Business Central partner license to old database
By using the Dynamics NAV Development Environment that matches the old database, upload the Business Central license to the database.

Task 4: Delete all objects except tables in old database

Task 5: Clear server instance and debugger breakpoint records in old database
-- Stop DynamicsNAV100 Instance
-- Delete Server instance record and breakpoint records from the old database
* DELETE FROM [Demo Database NAV (10-0) - Modified].[dbo].[Server Instance]
* DELETE from [Demo Database NAV (10-0) - Modified].[dbo].[Debugger Breakpoint]

Task 6: Convert old database to Business Central
"To convert the old database to the Business Central format, open the old database in the new Dynamics NAV Development Environment for Business Central, and follow the conversion instructions."
-- Open Business Central Development Environment --> Open this Old database [Demo Database NAV (10-0) - Modified] in it and do the conversion process
-- Before Conversion Close all the Active Sessions of old version: in our case -> Open Task Manager -> End process for "Microsoft Dynamics NAV"
-- Also close the Query Window if any open for this old database

*** Important: Do not run schema synchronization at this time. Choose to run it later.

Task 7: Import upgraded application objects to converted database
* Export the MigratedDB Objects first using following commands:
-> Export-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "MigratedDB" –Path C:\MigratedApplicationCodeObject\MigratedDBObjects.txt -Filter 'Id=1..1999999999'

Using Dynamics NAV Development Environment for Business Central, import the application objects that you want in the database. This includes the application objects FOB file (from the application code upgrade) and the upgrade toolkit objects FOB file.
1. Import the application objects FOB file first, and then import the upgrade toolkit FOB file.
2. IMPORTANT When prompted about table synchronization, set the Synchronize Schema option to Later.
3. When you import the FOB file, if you experience metadata conflicts, the Import Worksheet windows appears.
Review the Worksheet page. For more information, see Import Worksheet.
Choose Replace All, and then OK to continue.

* Import MigratedDB objects in converted db [Demo Database NAV (10-0) - Modified]
Import-NAVApplicationObject –DatabaseServer "LPTNOMOF06\NAVDEMO" –DatabaseName "Demo Database NAV (10-0) - Modified" –Path C:\MigratedApplicationCodeObject\MigratedDBObjects.txt

Task 8: Connect a Business Central Server instance to converted database
* Add an new instance in using Administration console for newly converted db in Business Central Admin Console or update any old Business Central instance with the converted database

*** Important: "When upgrading a large database, you should increase the SQL Command Timeout setting for the Business Central Server instance, to avoid timeouts during schema synchronization. The default setting is 30 minutes."

Task 9: Compile all objects in converted database
* In the Dynamics NAV Development Environment, set it to use the server instance that connects to the database.
* Use the Dynamics NAV Development Environment or finsql.exe to compile all objects. This includes the imported application objects, data tables, and system tables.

*** Important: "Choose to run schema synchronization later. For example, in Object Designer, choose Tools, choose Compile, set the Synchronize Schema option to Later, and then choose OK."

**** No need to work on Task 10 for this conversion
Task 10: (Upgrade from Dynamics NAV 2018 or Business Central Fall 2018 only ) Increase the application version of converted database
* You must increase the application version that is assigned to the database.
"Use the Set-NAVApplication cmdlet of the Business Central Administration Shell to increase the application version number of the database from its current version."
* To see the current version, use the following command:
Get-NAVApplication -ServerInstance <ServerInstanceName>
* To increase the version by 1, run the following command:
Set-NAVApplication -ServerInstance <ServerInstanceName> -IncrementApplicationVersion
* Or, to specify change to another version, run the following command:
Set-NAVApplication -ServerInstance <ServerInstanceName> -ApplicationVersion <N.N.N.N> -Force
** For example, if the old version was 11.0.24279.0, then you could change the version to 14.0.24279.0.
**** No need to work on Task 10 for this conversion

Task 11: Run the schema synchronization on converted database
* Synchronize the database schema with validation.
"For example, run the Sync-NAVTenant cmdlet from the Business Central Administration Shell."
* Sync-NAVTenant -ServerInstance <ServerInstanceName>
* e.g.: Sync-NAVTenant -ServerInstance bc130
* When completed, the tenant (database) should have the status OperationalDataUpgradePending. To verify this, run the following cmdlet:
* Get-NAVTenant -ServerInstance <ServerInstanceName> -tenant default
* e.g.: Get-NAVTenant -ServerInstance bc130 -tenant default

Task 12: Run data upgrade on converted database
"A data upgrade runs the upgrade toolkit objects, such as upgrade codeunits and upgrade tables, to migrate business data from the old table structure to the new table structure. You can start the data upgrade from the Dynamics NAV Development Environment or Business Central Administration Shell."

* Open the Business Central Administration Shell as an administrator, and then run Start-NavDataUpgrade cmdlet as follows:
* Start-NavDataUpgrade -ServerInstance <ServerInstanceName>
* e.g.: Start-NavDataUpgrade -ServerInstance bc130
"Replace <ServerInstanceName> with the name of the Business Central Server instance that is connected to the database."

"To view the progress of the data upgrade, you can run Get-NavDataUpgrade cmdlet with the –Progress switch."

"The data upgrade process runs CheckPreconditions and Upgrade functions in the upgrade codeunits. If any of the preconditions are not met or an upgrade function fails, you must correct the error and resume the data upgrade process. If CheckPreconditions and Upgrade functions are executed successfully, codeunit 2 is automatically run to initialize all companies in the database unless you set the -SkipCompanyIntitialization parameter."


Task 13: Upgrade Javascript-based control add-ins to new versions

Task 14: Publish and install/upgrade extensions

Task 15: Import permission sets and permissions

Task 16: (Optional) Import data encryption key

Task 17: Set the language of customer database

Task 18: (Optional) Update Web Server instance configuration file

(Optional) Task 19: Delete upgrade objects

 

I hope this article will help you during migration.

Stay Tuned!

Add comment