Esempio n. 1
0
        /// <summary>
        /// Executes the given migrations on the specified database.
        /// </summary>
        /// <param name="connectionStringOrConnectionStringName">Specifies a connection string or the name of a connection string in the current application configuration file to use.</param>
        /// <param name="migrations">Supplies the migrations to be executed.</param>
        /// <param name="options">Optionally specifies some custom options to use.</param>
        public static void Migrate(string connectionStringOrConnectionStringName, Migrations migrations,
                                   Options options = null)
        {
            options = options ?? new Options();

#if NET45
            var connectionString = ConfigurationManager.ConnectionStrings[connectionStringOrConnectionStringName]
                                   ?.ConnectionString
                                   ?? connectionStringOrConnectionStringName;
#else
            var connectionString = connectionStringOrConnectionStringName;
#endif

            var writer = options.GetWriter();

            var migrator = new DatabaseMigratorCore(connectionString, options, GetDatabase());

            //var migrator = new DatabaseMigratorCore(
            //    db: GetDatabase(),
            //    migrationTableName: options.MigrationTableName,
            //    writer: writer,
            //    connectionString: connectionString);

            var executableSqlMigrations = migrations.GetMigrations();

            migrator.Execute(executableSqlMigrations);
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the given migrations on the specified database.
        /// </summary>
        /// <param name="connectionString">Specifies a connection string or the name of a connection string in the current application configuration file to use.</param>
        /// <param name="migrations">Supplies the migrations to be executed.</param>
        /// <param name="options">Optionally specifies some custom options to use.</param>
        public static void Migrate(string connectionString, Migrations migrations, Options options = null)
        {
            options = options ?? new Options();

            //var writer = options.GetWriter();

            var migrator = new DatabaseMigratorCore(connectionString, options, GetDatabase());

            //var migrator = new DatabaseMigratorCore(
            //    db: GetDatabase(),
            //    migrationTableName: options.MigrationTableName,
            //    writer: writer,
            //    connectionString: connectionString);

            var executableSqlMigrations = migrations.GetMigrations();

            migrator.Execute(executableSqlMigrations);
        }
Esempio n. 3
0
        /// <summary>
        /// Executes the given migrations on the specified database.
        /// </summary>
        /// <param name="connectionStringOrConnectionStringName">Specifies a connection string or the name of a connection string in the current application configuration file to use.</param>
        /// <param name="migrations">Supplies the migrations to be executed.</param>
        /// <param name="options">Optionally specifies some custom options to use.</param>
        public static void Migrate(string connectionStringOrConnectionStringName, Migrations migrations, Options options = null)
        {
            options = options ?? new Options();

            var connectionString = ConfigurationManager.ConnectionStrings[connectionStringOrConnectionStringName]?.ConnectionString
                                   ?? connectionStringOrConnectionStringName;

            var writer = options.GetWriter();

            var migrator = new DatabaseMigratorCore(
                db: GetDatabase(),
                migrationTableName: options.MigrationTableName,
                writer: writer,
                connectionString: connectionString);

            var executableSqlMigrations = migrations.GetMigrations();

            migrator.Execute(executableSqlMigrations);
        }