public static void ClassInit(TestContext testContext) { if (_init == false) { //drop and recreate the test Db everytime the tests are run. AppDomain.CurrentDomain.SetData("DataDirectory", testContext.TestDeploymentDir); using (var uow = new UnitOfWork<CNCLibContext>()) { var x = uow.Context; // ref to get loaded System.Data.Entity.Database.SetInitializer<CNCLibContext>(new CNCLibInitializerTest()); uow.InitializeDatabase(); var o = uow.Context.Items.Where(i => i.ItemID == 0).FirstOrDefault(); // force init } _init = true; } }