Unit test with SQL Compact CE
I'm trying to unit test a set of fonctionalities. I would like to have a new database crated and deleted after each test or group of tests. Get the local Unit test path and a special folder string path = string.Format("{0}\\{1}", AppDomain.CurrentDomain.BaseDirectory, "UT"); <-- Create your directory or not --> initialization of the database name and dbcontext. YourDbContext dbContext = new YourDbContext ("Test" + DateTime.Now.ToFileTime()); SqlceConnectionFactory config SqlCeConnectionFactory sqce = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0",path,""); Last steps Database.DefaultConnectionFactory = sqce; dbContext.Database.Create(); and here do something













