Let’s say you just took a database back up from your D365 environment and want to import the .bacpac file to your development environment.

To do this, you might follow the import wizard and the steps found in this article:  https://www.sqlshack.com/importing-a-bacpac-file-for-a-sql-database-using-ssms/

However, there may be an import where the process times out and is unsuccessful.

In this case, need to increase the timeout on the import and to do this we can import via the command line like so:

SqlPackage.exe /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn:<target database name> /p:CommandTimeout=1200

Reference: https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/database/import-database

However, this approach will give us the following error:

*** Changes to connection setting default values were incorporated in a recent release.  More information is available at https://aka.ms/dacfx-connection
*** Error importing database:Could not import package.
Changes to connection setting default values were incorporated in a recent release.  More information is available at https://aka.ms/dacfx-connection
Unable to connect to target server 'localhost'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server.
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
The certificate chain was issued by an authority that is not trusted.
*** The settings for connection encryption or server certificate trust may lead to connection failure if the server is not properly configured.
Time elapsed 0:00:03.45

Following the link we can see some more information about additional parameters needed.

https://techcommunity.microsoft.com/t5/azure-sql-blog/connection-security-improvements-in-sqlpackage-161/ba-p/3672758

Here we see we need to update our command to be as follows:

SqlPackage.exe /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn:<target database name> /p:CommandTimeout=1200 /TargetTrustServerCertificate:True

Additionally, if you do not have SqlPackage.exe you can download it here:

https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver16

To use it, you need to first unzip the package. Then you can reference the path to the sqlpackage.exe executable in your command like so:

"PATH/TO/sqlpackage.exe" /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn:<target database name> /p:CommandTimeout=1200 /TargetTrustServerCertificate:True

Let the import process run, once complete you will see the newly imported database in SSMS. From here in order to use the database you need to:

  • Stop the services:
  1. Management Reporter 2012 Process Service
  2. Microsoft Dynamics 365 Unified Operations: Batch Management Service
  3. World Wide Web Publishing Service
  • Rename the database AxDB to a different name (AxDB_orig)
  1. Note this will not successfully rename if the database is in use by any running process, like Visual Studios.
  • Rename the newly import database to AxDB
  • Restart the previously stopped services
  • Open Visual studio and run a full sync.

Then you are off and running with your new database!

Keep reading about D365 tips and tricks here: https://markedcode.com/index.php/category/d365/

Author

2 Comments

  1. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it. You have made my day! Thank you again

Write A Comment