Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish DACPAC file to a SQL Server database project via SQLPackage.exe of SSDT?

I'm using SSDT for Visual Studio 2012 here and using its command-line tool SQLPackage.exe to publish a .dacpac file.

I want to publish that to an SQL Server database project. I'm trying to use parameter at this guide but cannot find ways how to do it.

How can I do that?

like image 221
Nam G VU Avatar asked Dec 11 '13 07:12

Nam G VU


People also ask

How do I publish a Dacpac file?

A simple command would be "sqlpackage /a:publish /sf:db1. dacpac /tsn:localhost /tdn:db1" to publish dacpac "db1" to a database "localhost\db1". For other publish options type "sqlpackage /a:publish /?" to get the list of applicable actions on the command line.

How do I open a Dacpac file in SQL Server?

In Windows Explorer, right-click the DACPAC file you want to use, and click Unpack. The Unpack Microsoft SQL Server DAC Package File dialog opens. Specify the folder you want the files in the DACPAC to be unpacked to, and click Unpack: DACPACs contain a model.


1 Answers

Are you trying to publish to a Database, or create a database project from a dacpac? These are two different things.

  • To create a database project based on a dacpac, create a new SQL Server Database Project in Visual Studio. Then right-click on the project in Solution Explorer and choose "Import -> Data-tier Application (*.dacpac)" and select your dacpac. That will convert the contents of the dacpac into scripts in the project, and if you choose "Import database settings" the database options will be set based on the settings in the dacpac. Unfortunately there's no way to do this via a command line tool that I'm aware of.

  • To use SqlPackage.exe to publish to a database, the guide you linked to has all the options. A simple command would be "sqlpackage /a:publish /sf:db1.dacpac /tsn:localhost /tdn:db1" to publish dacpac "db1" to a database "localhost\db1". For other publish options type "sqlpackage /a:publish /?" to get the list of applicable actions on the command line.

like image 83
Kevin Cunnane Avatar answered Oct 05 '22 13:10

Kevin Cunnane