7

Is it possible to get VS to drop the destination database before a deploy?

I've tried adding a post deploy script to the project, but it always comes back with active connections.

2 Answers 2

6

You'll need to look up the Always recreate database option in the properties of the database project -> Deploy -> Deployment configuration file -> Edit Dialog.

Another option "Drop objects that exist in the target database but not in the schema" can also be useful to you.

Sign up to request clarification or add additional context in comments.

3 Comments

Just what I was looking, as always they do it first :) Thanks!
Sometimes there's more to it... check last reply of 'noonie' on social.msdn.microsoft.com/Forums/en/vstsdb/thread/…. "And I've found out why you are getting the drop database in your script. If you have not set a Target connection (or subsequently cleared the previous setting) the deploy process adds the drop & create statements to the .sql file regardless of the setting in the Database.sqldeployment file."
I'm not seeing this in VS 2019. Where is the setting?
1
+500

You should check the Always re-create database option under publish.

DB Project -> Right Click -> Publish -> Advanced

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.