I am working on creating a visual studio database solution so that i could deploy databases in a more managed manner. Following are the steps that i performed after adding some sample tables and SPs in the solution.
- Deploy the database to my local machine (and a new database is created).
- Add some mock data to the tables in SSMS.
- Add couple of columns to one of the tables in the VS 2010 solution.
- Build the solution and deploy the database again (this time it deploys only the changes made to the schema).
- Verfiy that the existing data was intact and new columns have been added to the table schema.
Everything is working as expected till this point.
- Now I delete the database manually which was created by the deployment.
Go to VS 2010 and deploy the solution (expecting that it should do a clean deployment of the database), however i get the following error :
------ Deploy started: Project: MyDatabase, Configuration: Debug Any CPU ------
Pre-Deploy: Starting script execution…
Pre-Deploy: Finished script execution.
MyDatabase.dacpac(0,0): Error : -->Cannot upgrade the DAC for database MyDatabase, a database with that name does not exist. Specify a valid database name.
Is there any setting in my solution where i could specify that the deployment should do a clean install if the database does not exist?
Or
Do i need to write separate (database creation) scripts if the database does not exist?