private bool CreateDatabase(Action <DbContext> clean) { var connectionString = CreateConnectionString(Name); if (JetConnection.DatabaseExists(connectionString)) { // Only reseed scripted databases during CI runs if (_scriptPath != null && _templatePath == null && !TestEnvironment.IsCI) { //return false; } // Delete the database to ensure it's recreated with the correct file path DeleteDatabase(); } if (_templatePath != null) { File.Copy(_templatePath, Name); } else { JetConnection.CreateDatabase(Name); } return(true); }
public void Initialize() { if (!JetConnection.DatabaseExists(ConnectionString)) { JetConnection.CreateEmptyDatabase(ConnectionString); } using (JetConnection connection = new JetConnection(ConnectionString)) { connection.Open(); if (!connection.TableExists("SimpleTable")) { connection.CreateCommand("CREATE TABLE SimpleTable ( Col varchar(10) )").ExecuteNonQuery(); } connection.CreateCommand("DELETE FROM SimpleTable").ExecuteNonQuery(); } JetConnection.ClearAllPools(); }
public bool Exists() { return(_connection.DatabaseExists()); }