Reputation: 3659
I'm trying to setup SQL Server CE 4.0 as my Test Database in order to run integration tests, as described in this article: http://lostechies.com/erichexter/2013/01/06/using-sql-compact-for-integration-tests-with-entity-framework/
These are all the projects in my solution:
I added a SQL Compact CE 4.0 reference and connectionString to the app.config file on the UnitTests project and then tried to run the update-database command:
update-database -ProjectName DataAccessLayer -StartupProjectName UnitTests -Verbose
This works fine for most migrations but it stops short of finishing and then I get this error:
Direct column renaming is not supported by SQL Server Compact. To rename a column in SQL Server Compact, you will need to recreate it.
Is there a way that I can turn off migrations and just re-create the entire database JUST for the unit tests projects?
Upvotes: 1
Views: 812
Reputation: 3659
Found it. Just had to set the Database initializer on the unit tests project:
System.Data.Entity.Database.SetInitializer(new DropCreateDatabaseAlways<MyContext>());
I call this from the FixtureSetup method on my unit test project.
Upvotes: 1