public static void CreateIfNotExists(this IDatabaseProvider databaseProvider) { if (!databaseProvider.Exists()) { databaseProvider.Create(); } }
public string Create() { var schemaExport = new SchemaExport(configuration); databaseProvider.CreateIfNotExists(); var stringBuilder = new StringBuilder(); schemaExport.Create(x => stringBuilder.Append(x), false); var statement = stringBuilder.ToString(); statement = string.IsNullOrWhiteSpace(statement) ? null : statement; if (!databaseProvider.Exists()) { databaseProvider.Create(); schemaExport.Execute(false, true, false); } else { try { new SchemaValidator(configuration).Validate(); } catch { schemaExport.Execute(false, true, false); } } return(statement); }
public static void DropIfExistsAndCreate(this IDatabaseProvider databaseProvider) { if (databaseProvider.Exists()) { databaseProvider.Drop(); } databaseProvider.Create(); }