Let’s say you just took a database backup from your Microsoft Dynamics 365 for Finance & Supply Chain Management 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:
- Management Reporter 2012 Process Service
- Microsoft Dynamics 365 Unified Operations: Batch Management Service
- World Wide Web Publishing Service
- Rename the database AxDB to a different name (AxDB_orig).
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! For more D365 tech advice, connect with us here.
Post previously published https://markedcode.com/index.php/2022/11/16/import-bacpac-to-ssms/
This publication contains general information only and Sikich is not, by means of this publication, rendering accounting, business, financial, investment, legal, tax, or any other professional advice or services. This publication is not a substitute for such professional advice or services, nor should you use it as a basis for any decision, action or omission that may affect you or your business. Before making any decision, taking any action or omitting an action that may affect you or your business, you should consult a qualified professional advisor. In addition, this publication may contain certain content generated by an artificial intelligence (AI) language model. You acknowledge that Sikich shall not be responsible for any loss sustained by you or any person who relies on this publication.