public void UpdateDatabase() { var migrationConfiguration = new Migrations.Configuration(); var migrator = new DbMigrator(migrationConfiguration); migrator.Update(); }
public void Configuration(IAppBuilder app) { // If we are using the Azure Storage Emulator we need to make sure it is installed and started. if (ConfigurationManager.AppSettings["BlobStorageConnectionString"] == "UseDevelopmentStorage=true" || ConfigurationManager.AppSettings["BlobStorageConnectionString"] == "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;TableEndpoint=http://localhost:10002/devstoreaccount1;QueueEndpoint=http://localhost:10001/devstoreaccount1;") { //AzureStorageEmulatorManager.Start(); // We start Azure Storage Emulator manually instead. } // Should we check for pending database migrations and apply them? if (bool.Parse(ConfigurationManager.AppSettings["checkForPendingDatabaseMigrations"])) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); if (migrator.GetPendingMigrations().Count() > 0) { migrator.Update(); } } Bootstrapper.Initialise(); // Any connection or hub wire up and configuration should go here app.MapSignalR(); }
public static void InitialiseDatabase() { var mc = new Migrations.Configuration(); var dm = new DbMigrator(mc); dm.Update(); }
private static void MigrateDbToLatestVersion() { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); }
/// <summary> /// This is caling the migrations from GildedRose project. /// This will run every time but the actual DB creation will happen only /// if there is no existing DB. /// <remarks> /// SEEDS: /// Users table - 1 /// Items table - 4 /// </remarks> /// </summary> private void InitializeDatabase() { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); }
public ActionResult DatabaseSeed() { var config = new Migrations.Configuration(); config.ReSeed(this.DBContext); return(RedirectToAction("Index")); }
public static void UpgradeDatabase() { var migratorConfig = new Migrations.Configuration(); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); }
protected void Application_Start() { WebApiConfig.Register(); var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); }
public ActionResult DropSchema() { //Sistrategia.Drive.Data.DatabaseManager.DropSchema(); var configuration = new Migrations.Configuration(); var migrator = new System.Data.Entity.Migrations.DbMigrator(configuration); migrator.Update("0"); return Redirect("~/Dev"); }
public void TestInitialize() { _accountController = new AccountController(ContextEnum.BeatBuddyTest); var migratorConfig = new Migrations.Configuration(); migratorConfig.TargetDatabase = new DbConnectionInfo(ContextEnum.BeatBuddyTest.ToString()); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); }
public static ApplicationDbContext Create() { var migratorConfig = new Migrations.Configuration(); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); return(new ApplicationDbContext()); }
protected void Application_Start() { // Make sure we run migrations var migrationConfig = new Migrations.Configuration(); var dbMigrator = new DbMigrator(migrationConfig); dbMigrator.Update(); GlobalConfiguration.Configure(WebApiConfig.Register); }
public static void PerformUpgrade() { var config = new Migrations.Configuration { AutomaticMigrationsEnabled = false }; var migrator = new DbMigrator(config); migrator.Update(); }
public ActionResult Uninstall() { if (Request.IsLocal) { var config = new Migrations.Configuration(); config.Uninstall(db); } return(RedirectToAction("Index")); }
public static void Initialize() { var migratorConfig = new Migrations.Configuration(); migratorConfig.TargetDatabase = new DbConnectionInfo(ContextEnum.BeatBuddyTest.ToString()); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); }
public static void EnableCodeFirstMigrations() { if (bool.Parse(ConfigurationManager.AppSettings["MigrateDatabaseToLatestVersion"])) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); } }
public static void RunMigrationsOnStartup() { if (bool.Parse(RoleEnvironment.GetConfigurationSettingValue("MigrateDatabaseToLatestVersion"))) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); } }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); if (bool.Parse(ConfigurationManager.AppSettings["MigrateDatabaseToLatestVersion"])) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); } }
public static void EnableCodeFirstMigrations() { if (bool.Parse(ConfigurationManager.AppSettings["checkForPendingDatabaseMigrations"])) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); if (migrator.GetPendingMigrations().Count() > 0) { migrator.Update(); } } }
public ActionResult Login(string returnUrl) { if (System.AppDomain.CurrentDomain.BaseDirectory.StartsWith("D:\\")) { var config = new Migrations.Configuration(); var migrator = new DbMigrator(config); migrator.Update(); } ViewBag.ReturnUrl = returnUrl; return View(); }
public static void Upgrade(DbConnectionInfo database = null) { var configuration = new Migrations.Configuration(); if (database != null) { configuration.TargetDatabase = database; } var migrator = new DbMigrator(configuration); migrator.Update(); }
protected void Application_Start() { // Enable automatic migration var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
private static void UpdateMigration() { try { var migratorConfig = new Migrations.Configuration(); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public void Setup() { AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Directory.GetCurrentDirectory()); this.dbContextFactory = () => new MainContext(CONNECTION); using (var dbCtx = this.dbContextFactory()) { dbCtx.Database.CreateIfNotExists(); var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration, dbCtx); migrator.Update(); } }
public static bool Migrate(out string msg) { try { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); msg = ""; return(true); } catch (Exception ex) { msg = ex.Message; return(false); } }
private void DoMigrations() { const string sqlClient = "System.Data.SqlClient"; var connectionString = ConfigurationManager.ConnectionStrings["SimpleDatabaseRestore"]; if (string.IsNullOrEmpty(connectionString.ProviderName) || !connectionString.ProviderName.Equals(sqlClient, StringComparison.OrdinalIgnoreCase)) { return; } System.Data.Entity.Database.SetInitializer<SimpleDatabaseRestoreDbContext>(null); var settings = new Migrations.Configuration(); var migrator = new DbMigrator(settings); migrator.Update(); }
public static void DeleteAllFromDb() { var repo = new DvdRepositoryEntity(); var dvds = repo.GetAll().ToList(); // movie exists? foreach (var dvd in dvds) { int id = dvd.DvdId; repo.Delete(id); } Migrations.Configuration configuration = new Migrations.Configuration(); DvdLibraryEntities entities = new DvdLibraryEntities(); configuration.Seed(entities); }
private static void DoMigrations() { // Get the Jabbr connection string var connectionString = ConfigurationManager.ConnectionStrings["HipChatDbContext"]; if (String.IsNullOrEmpty(connectionString.ProviderName) || !connectionString.ProviderName.Equals(SqlClient, StringComparison.OrdinalIgnoreCase)) { return; } Database.SetInitializer<HipChatDbContext>(null); // Only run migrations for SQL server (Sql ce not supported as yet) var settings = new Migrations.Configuration(); var migrator = new DbMigrator(settings); migrator.Update(); }
public void MigrateDatabase() { var migrationsConfiguration = new Migrations.Configuration(); var connectionInfo = new DbConnectionInfo( _context.Database.Connection.ConnectionString, DatabaseConfiguration.DefaultProvider); migrationsConfiguration.TargetDatabase = connectionInfo; var migrator = new DbMigrator(migrationsConfiguration); var pendingMigrations = migrator.GetPendingMigrations(); if (pendingMigrations.Any()) { migrator.Update(); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); try { if (bool.Parse(ConfigurationManager.AppSettings["MigrateDatabaseToLatestVersion"])) { var configuration = new Migrations.Configuration(); var migrator = new DbMigrator(configuration); migrator.Update(); } } catch (ArgumentNullException) { Trace.TraceWarning("MigrateDatabaseToLatestVersion key is null. Database not migrated."); } }
/// <summary> /// Открыть БД с выполнением автоматической миграции /// </summary> /// <returns></returns> public static DB Open() { // Инициализатор с поддержкой миграции БД Database.SetInitializer(new MigrateDatabaseToLatestVersion <DB, Migrations.Configuration>()); var db = new DB(); bool doMiration = false; try { doMiration = !db.Database.CompatibleWithModel(true); } catch (Exception) { doMiration = true; } if (doMiration) { var cfg = new Migrations.Configuration(); var mgr = new DbMigrator(cfg); mgr.Update(); } return(db); }
private static void DoMigrations() { var settings = new Migrations.Configuration(); var migrator = new DbMigrator(settings); migrator.Update(); }
public static void Init() { string fullPluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"); // If no Plugins Directory if found then there is no need to continue if (!Directory.Exists(fullPluginPath)) { return; } // First check to see if we need to remove any dll's so we can install a new one using (var context = new DataContext()) { SiteSettings siteSettings = null; try { siteSettings = context.SiteSettings.FirstOrDefault(); } catch (Exception e) { // Catch Model Update issue // If model can be updated without data loss, go for it var migratorConfig = new Migrations.Configuration(); var dbMigrator = new DbMigrator(migratorConfig); dbMigrator.Update(); } if (siteSettings != null && !String.IsNullOrEmpty(siteSettings.RMPluginDLLPath)) { // Remove the dll if (File.Exists(siteSettings.RMPluginDLLPath)) { try { File.Delete(siteSettings.RMPluginDLLPath); // Reset the path then reset the app pool again siteSettings.RMPluginDLLPath = String.Empty; context.SaveChanges(); } catch (Exception e) { // Probably had a file lock - should log to notificaitons api } } // Remove the dll's folder if it exists string pluginDir = siteSettings.RMPluginDLLPath.Replace(".dll", ""); if (Directory.Exists(pluginDir)) { Directory.Delete(pluginDir, true); } } } // Now check to see if we need to extract any plugins foreach (var file in Directory.EnumerateFiles(fullPluginPath, "*.zip")) { try { // Extract Zip File ZipFile.ExtractToDirectory(file, fullPluginPath); // Delete the Zip file now that it has been extracted File.Delete(file); } catch (Exception e) { // Gotta.. catch.. } } // Finally, load all plugins foreach (var file in Directory.EnumerateFiles(fullPluginPath, "*.dll")) { PluginAssemblies.Add(Assembly.LoadFile(file)); } PluginAssemblies.ForEach(BuildManager.AddReferencedAssembly); }
protected void btnSetUp_Click(object sender, EventArgs e) { Migrations.Configuration AppSetUp = new Migrations.Configuration(); AppSetUp.ApplicationSetUp(); lblMessage.Text = "Success!! Application set up completed successfully."; }
public void SeedDatabase() { MyHobby.Migrations.Configuration config = new Migrations.Configuration(); config.CallSeed(_context); }
public ActionResult DatabaseSeed() { var config = new Migrations.Configuration(); config.ReSeed(this.DBContext); return RedirectToAction("Index"); }