Question

I have a VS 2012 solution that includes both an SSDT project (sqlproj) and an MVC Web Application. I've setup numerous profiles for deploying the web app and would now like to use dbdacfx (or something else?) to deploy the dacpac produced by the SSDT project. I've tested the dacpac itself and it works flawlessly. However, figuring out how to integrate the two is proving elusive. Every example I've seen for deploying incremental database changes with Web Deployment seems to want an instance of the database - how do I get it to use my existing dacpac instead?

Hopefully I'm asking the right question :)

Thanks!

Was it helpful?

Solution

Assuming you've already got a dacpac file that you want to deploy, you can use SQLPackage.exe to deploy it. Using PowerShell:

& "C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" /sf:"MyProject.Database.dacpac" /a:publish /TargetConnectionString:$DBConnectionString /p:VerifyDeployment=true /p:CreateNewDatabase=$CreateNewDatabase | Out-Default

This assumes the script is parallel with your dacpac file, and the following variables are defined:

  • $DBConnectionString - Database connection string.
  • $CreateNewDatabase - Whether to create a new database if it does not exist.

There are more options you can pass in: http://msdn.microsoft.com/en-us/library/hh550080%28v=vs.103%29.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top