How to re-deploy, re-create database on each test run

前端 未结 3 950
鱼传尺愫
鱼传尺愫 2021-01-05 14:11

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 m

3条回答
  •  长发绾君心
    2021-01-05 14:50

    Edit: Although this doesn't answer the question in a plain SQL Server way, an easy Entity Framework approach would be the following: I found that I could create and destroy my database every time correctly by using the DbContext.Database.CreateIfNotExists() and DbContext.Database.Delete() methods in my setup and cleanup phases of my tests.

提交回复
热议问题