Dynamics 365 For Finance and Operations database import in dev environment using SQL

 

About import

The process of database import is needed when a new developer starts to work on a project and requires configured data for performing testing scenarios.

In our projects we use preconfigured user data to improve our development and testing performance. We store a Tier 1 environment database backup (.bak) and use it when a new developer comes to work with a project.

As Microsoft releases platform updates, we need, somehow, to use old backups from environments of older versions, for data import on Tier 1 developer environments.

Keep in mind, that this article considers only Tier 1 environments.

This instruction can be used to import and work with databases for different projects.

Import database

To import database a developer needs to have the database backup.

Importatnt! For this operation you need to use Tier 1 database backup (.bak).

1. Download database backup.

The database backup can be found in Asset Library of LCS (LifeCycle Services) project, as it is shown on picture 1. You need to download it to the SQLBACKUP disk on Tier 1 DEV machine.

If you do not have rights to enter this project, contact your system administrator.

Picture 3. Choose Maintain -> Apply Updates
Or you can take the backup from the SQL also works.

2. Create new database.

After you connected to your work server in SSMS(Microsoft SQL Server management Studio) you need to Right click on Databases folder and choose “Restore database”. In table 1 are show settings for database restoration. This process will create a new database called AxDB_new.

Table 1. Settings for database restoration

Table 1. Settings for database restoration


Click on the File tab and changes the New name of the DB


Picture 2. Restore database

3. Run script to alter database.

After performing steps above, you need to change current main database to imported one. To perform this operation use script below:

Code to restore database
--set main db to single connections and drop the existing connections

ALTER DATABASE AxDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE

--rename datbase to db_old

ALTER DATABASE AxDB MODIFY NAME = AxDB_old

--set the old db to multi user

ALTER DATABASE AxDB_old SET MULTI_USER

--rename the new db to the main db name

ALTER DATABASE AxDB_new MODIFY NAME = AxDB  

Now your environment is ready to perform data upgrade operation.

Perform data upgrade.

To perform data upgrade you need to know platform update and application version of your environment. This information can be found in LCS.

1. Run apply updates command.

To apply an update to environment in LCS you need to find your environment in LCS project and select command Maintain -> Apply Updates as it showed on picture 3.

Picture 3. Choose Maintain -> Apply Updates

Picture 3. Choose Maintain -> Apply Updates

2. Select data upgrade package and apply.

In the opened menu select necessary data upgrade package and apply it to your environment.

To choose right package you need to know Application release and Platform update of your environment as it showed on picture 4.

Before applying a package close all programs on your target environment.

Picture 4. Apply update package

Picture 4. Apply update package

3. Wait until operation of update will end.

If it is necessary perform error fixing during apply package operation.

Create Administrator user.

To be able to use D365FO environment from user perspective, you need to create an administrator user.

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++