Database Project to Drop Database before deploy?
Asked Answered
M

2

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.

Mannerheim answered 6/7, 2010 at 14:38 Comment(0)
K
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.

Knudson answered 6/7, 2010 at 14:49 Comment(3)
Just what I was looking, as always they do it first :) Thanks!Seaworthy
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."Ribband
I'm not seeing this in VS 2019. Where is the setting?Mackenzie
A
1

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

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

enter image description here

Ardennes answered 11/6, 2019 at 17:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.