private void MigratorRegister() { ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration(); using (var migrator = new Migrator("ECM7.Migrator.Providers.SqlServer.SqlServerTransformationProvider, " + "ECM7.Migrator.Providers.SqlServer", applicationConfiguration.ConnectionString, Assembly.Load("GroupBuy.Data"))) { migrator.Migrate(); } }
private void UpdateDatabase(IDbConnection connection, Plugin plugin) { var assembly = plugin.GetType().Assembly; logger.Info("update database: {0}", assembly.FullName); // todo: sql var provider = ProviderFactory.Create<SqlServerCeTransformationProvider>(connection, null); //var provider = ProviderFactory.Create<SqlServerTransformationProvider>(connection, null); using (var migrator = new Migrator(provider, assembly)) { // запрещаем выполнять миграции, для которых не указано "пространство имен" if (migrator.AvailableMigrations.Any()) { var migrationsInfo = assembly.GetCustomAttribute<MigrationAssemblyAttribute>(); if (migrationsInfo == null || string.IsNullOrWhiteSpace(migrationsInfo.Key)) { logger.Error("assembly {0} contains invalid migration info", assembly.FullName); } } migrator.Migrate(); } }