How to re-deploy, re-create database on each test run
mstest, sql-server-2012, visual-studio, visual-studio-2012
Solution
As mentioned you'll probably want to use the VS 2012 .Local.testsettings > Setup and Cleanup scripts to create / tear down you SQL Server database.
For the script you may want to use powershell with a .dacpac (rather than just a T-SQL script), since you are using a SSDT project. Here's a link to some example code - in particular you may want to take a look at the 'Deploy-Dac' command.
If you are unfamiliar with .dacpacs as the (build) output of SSDT-created database projects, take a look at this reference link.
Problem
Currently I'm using Visual Studio 2012 RC and SQL Server 2012 RTM. I'd like to know how to re-deploy/re-create a test database for each test run. Keep in mind I've a SQL Server database project for the database using Visual Studio 2012's template. Actually I'm not very sure about an idea I got in my mind, but .testsettings file has Setup and cleanup scripts. Is this the way to go? For example, a PowerShell script reading the database project generated script and executing it against the database? I guess there're better ways of doing that and it should be an out-of-the-box solution but I ignore it and Google doesn't help me in finding the right solution.