public JoinMigrationsConfig(string connectionString) { TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo(connectionString, "System.Data.SqlClient"); MigrationsAssembly = typeof(MyDbContext).Assembly; MigrationsNamespace = typeof(MyDbContext).Namespace + ".Migrations"; ContextKey = "JoinRpg.Dal.Impl.Migrations.Configuration"; }
public ConfigurationInstall() { AutomaticMigrationsEnabled = true; AutomaticMigrationDataLossAllowed = BeYourMarketConfigurationManager.AutomaticMigrationDataLossAllowed; ContextKey = "BeYourMarket.Model.Models.BeYourMarketContext"; TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo("DefaultConnection"); }
public StripeDatabaseMigrationConfig() { AutomaticMigrationsEnabled = true; AutomaticMigrationDataLossAllowed = true; ContextKey = "Plugin.Payment.Stripe.Data.StripeContext"; TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo("DefaultConnection"); }
public AutoDbMigrationConfiguration() { AutomaticMigrationsEnabled = false; AutomaticMigrationDataLossAllowed = true; ContextKey = "AutoMoto.Model.Models.AutoDbContext"; TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo("DefaultConnection"); }
public Configuration() { TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo(ConnectionString, "MySql.Data.MySqlClient"); AutomaticMigrationsEnabled = true; AutomaticMigrationDataLossAllowed = false; SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator()); CodeGenerator = new MySql.Data.Entity.MySqlMigrationCodeGenerator(); }
public TestConfiguration(string connString) { AutomaticMigrationDataLossAllowed = true; AutomaticMigrationsEnabled = true; TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo(connString, "System.Data.SqlClient"); }
public static void Initialize(string connectionString) { var bld = new SqlConnectionStringBuilder(connectionString); //get name of database to connect var dbName = bld.InitialCatalog; //get connection string to Master database bld.InitialCatalog = "master"; var masterConnectionString = bld.ConnectionString; //create the database, if it doesn't exist bool shouldRunSeed = false; using (var cnn = new SqlConnection(masterConnectionString)) { var cmdString1 = string.Format("select * from sys.databases where name='{0}'", dbName); var cmdString2 = string.Format("create database {0}", dbName); int result; using (var cmd = new System.Data.SqlClient.SqlCommand(cmdString1, cnn)) { cmd.Connection.Open(); result = cmd.ExecuteNonQuery(); cmd.Connection.Close(); if (result == 0) { using (var cmd2 = new SqlCommand(cmdString2, cnn)) { cmd2.Connection.Open(); cmd2.ExecuteNonQuery(); } shouldRunSeed = true; } } } var connectionInfo = new System.Data.Entity.Infrastructure.DbConnectionInfo(connectionString, "System.Data.SqlClient"); var config = new DbMigrationsConfiguration(); config.TargetDatabase = connectionInfo; var migrator = new DbMigrator(config); migrator.Configuration.AutomaticMigrationDataLossAllowed = true; migrator.Configuration.AutomaticMigrationsEnabled = true; var pendingMigrations = migrator.GetPendingMigrations(); if (pendingMigrations.Any()) { System.Threading.Thread.Sleep(5000); migrator.Update(); if (shouldRunSeed) { var ctx2 = new DataContext(); Seed(ctx2); } } migrator.Configuration.AutomaticMigrationsEnabled = false; }
public ConfigurationInstall() { AutomaticMigrationsEnabled = true; TargetDatabase = new System.Data.Entity.Infrastructure.DbConnectionInfo("DefaultConnection"); }