Search code examples
sqlsql-servervisual-studio-2012deploymentsql-server-data-tools

How to add PostDeploy script during Schema Compare generate script


I am comparing the current version of my Database Project with a dacpac (previous version of the same database).

Then i hit the generate script button what gives me, as expected, the change script.

Unfortunately i does not add the Post deployment script to the change script.

If i use the "Publish Database" feature and compare against a "real" db it creates a update script with the post deploy script but i require this feature in the schema compare.

Is there any option i overlooked?

How did you solved the problem?


Solution

  • You need to actually publish the project to use the Post-Deploy and Pre-Deploy scripts. The Post-Deploy script is not part of the SQL Compare. The SQL Compare option only compares actual database options. I'd recommend using the Publish command, setting your options the way you want, then saving that as part of the project. You can easily use that to generate a script. You'll need to compare against a real database anyway in order to do a schema comparison, so this should be very similar to the option you're already using.