private static void Run(DBName dBName) { var connString = _configuration.GetConnectionString(dBName.ToString()); var scriptFolderPath = $"./Scripts/{dBName.ToString()}"; EnsureDatabase.For.PostgresqlDatabase(connString); var upgradeBuilder = DeployChanges.To .PostgresqlDatabase(connString) .WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "Scripts"), new SqlScriptOptions { RunGroupOrder = 1, ScriptType = ScriptType.RunOnce }) .WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "SeedData"), new SqlScriptOptions { RunGroupOrder = 2, ScriptType = ScriptType.RunOnce }); if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { upgradeBuilder.WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "SampleData"), new SqlScriptOptions { RunGroupOrder = 3, ScriptType = ScriptType.RunOnce }); } var upgrader = upgradeBuilder.LogToAutodetectedLog().Build(); upgrader.PerformUpgrade(); }
private static void Run(DBName dBName) { var connString = _configuration.GetConnectionString(dBName.ToString()); var scriptFolderPath = $"./Scripts/{dBName.ToString()}"; var upgrader = DeployChanges.To .PostgresqlDatabase(connString) .WithScriptsFromFileSystem(scriptFolderPath, new SqlScriptOptions { RunGroupOrder = DbUpDefaults.DefaultRunGroupOrder + 1 }) .LogToAutodetectedLog() .Build(); var result = upgrader.PerformUpgrade(); }
public static DbContext Create(DBName dbName) { DbContext dbContext = CallContext.GetData(dbName.ToString()) as DbContext; if (dbContext == null) { lock (locker) { if (dbContext == null) { switch (dbName) { case DBName.ChannelDB: //dbContext = new ChannelEntities(); //CallContext.SetData(dbName.ToString(), dbContext); break; case DBName.MpConfigDB: //dbContext = new MPDBEntities(); //CallContext.SetData(dbName.ToString(), dbContext); break; case DBName.ReservationDB: //dbContext = new yudingEntities(); //CallContext.SetData(dbName.ToString(), dbContext); break; case DBName.ITicketDB: dbContext = new iticketDB(); CallContext.SetData(dbName.ToString(), dbContext); break; default: dbContext = null; break; } } } } return(dbContext); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedItem.ToString()) { case "SQLite": SelectedDB = DBName.SQLite; SDB.Text = SelectedDB.ToString(); break; case "MySql": SelectedDB = DBName.MySql; SDB.Text = SelectedDB.ToString(); break; case "MSSQL": SelectedDB = DBName.MSSQL; SDB.Text = SelectedDB.ToString(); break; default: SelectedDB = DBName.SQLite; SDB.Text = SelectedDB.ToString(); break; } }
private DapperInfrastructure.DB GetNewDB(DBName dbName) { return(DapperInfrastructure.DB.New(dbName.ToString())); }