Database project to delete a database before deployment?

Is it possible to get VS to delete the destination database before deployment?

I tried to add a post-deployment script to the project, but it always returns with active connections.

+6
source share
3 answers

You need to find the Always recreate database option in the properties of the database project β†’ Deploy β†’ Deployment configuration file β†’ Edit dialog.

You may also find it useful another option: "Drop objects that exist in the target database, but not in the schema."

+6
source

You must select the Always re-create database option when publishing.

Database Project β†’ Right Click β†’ Publish β†’ Advanced

enter image description here

+1
source

In your post-deployment scenario, did you try to kill active connections first?

There's a good answer to this script to kill all database connections (more than RESTRICTED_USER ROLLBACK)

0
source

Source: https://habr.com/ru/post/1314846/


All Articles