コード例 #1
0
        /// <summary>
        /// Set up your migrator and call this to generate a diff file. Known limitations - will not detect size changes or renames. In other words, destructive changes will need to be done by hand.
        /// </summary>
        /// <param name="diffingType">Are you in greenfield development or have you went to production (maintenance)? Do you want it to restore during maintenance mode?</param>
        /// <param name="nameOfOutputScriptToCreateOrReplace">This is something like 0001_CreateTables.sql. This will end up in your up folder, assuming you have set up your migrator configuration correctly.</param>
        /// <param name="databaseMigrator">The Migrator to use when running.</param>
        /// <param name="mappingsAssembly">This is the assembly that contains your mapping files.</param>
        /// <param name="conventionsAssembly">This is the assembly that contains your conventions. If you do not have conventions set up, just pass null. It will use the mappingsAssembly</param>
        public void Run(RoundhousEFluentNHDiffingType diffingType, string nameOfOutputScriptToCreateOrReplace, Migrate databaseMigrator, Assembly mappingsAssembly, Assembly conventionsAssembly)
        {
            name_of_script_to_create = nameOfOutputScriptToCreateOrReplace;
            var configuration = databaseMigrator.GetConfiguration();

            configuration.Silent  = true;
            configuration.Restore = false;
            ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration);
            path_to_sql_scripts_up_folder = Path.Combine(configuration.SqlFilesDirectory, configuration.UpFolderName);

            databaseMigrator.Set(c =>
            {
                c.Silent      = true;
                c.VersionFile = mappingsAssembly.Location;
            }
                                 );

            switch (diffingType)
            {
            case RoundhousEFluentNHDiffingType.InitialDevelopment:
                run_initial_database_setup(databaseMigrator, configuration, mappingsAssembly, conventionsAssembly);
                break;

            case RoundhousEFluentNHDiffingType.Maintenance:
                run_maintenance_database_setup(false, databaseMigrator, configuration, mappingsAssembly, conventionsAssembly, name_of_script_to_create);
                break;

            case RoundhousEFluentNHDiffingType.MaintenanceWithRestore:
                run_maintenance_database_setup(true, databaseMigrator, configuration, mappingsAssembly, conventionsAssembly, name_of_script_to_create);
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Set up your migrator and call this to generate a diff file. Known limitations - will not detect size changes or renames. In other words, destructive changes will need to be done by hand.
        /// </summary>
        /// <param name="diffingType">Are you in greenfield development or have you went to production (maintenance)? Do you want it to restore during maintenance mode?</param>
        /// <param name="nameOfOutputScriptToCreateOrReplace">This is something like 0001_CreateTables.sql. This will end up in your up folder, assuming you have set up your migrator configuration correctly.</param>
        /// <param name="databaseMigrator">The Migrator to use when running.</param>
        /// <param name="mappingsAssembly">This is the assembly that contains your mapping files.</param>
        /// <param name="conventionsAssembly">This is the assembly that contains your conventions. If you do not have conventions set up, just pass null. It will use the mappingsAssembly</param>
        public void Run(RoundhousEFluentNHDiffingType diffingType, string nameOfOutputScriptToCreateOrReplace, Migrate databaseMigrator, Assembly mappingsAssembly, Assembly conventionsAssembly)
        {
            name_of_script_to_create = nameOfOutputScriptToCreateOrReplace;
            var configuration = databaseMigrator.GetConfiguration();
            configuration.Silent = true;
            configuration.Restore = false;
            ApplicationConfiguraton.set_defaults_if_properties_are_not_set(configuration);
            path_to_sql_scripts_up_folder = Path.Combine(configuration.SqlFilesDirectory, configuration.UpFolderName);

            databaseMigrator.Set(c =>
            {
                c.Silent = true;
                c.VersionFile = mappingsAssembly.Location;
            }
        );

            switch (diffingType)
            {
                case RoundhousEFluentNHDiffingType.InitialDevelopment:
                    run_initial_database_setup(databaseMigrator, configuration, mappingsAssembly, conventionsAssembly);
                    break;
                case RoundhousEFluentNHDiffingType.Maintenance:
                    run_maintenance_database_setup(false, databaseMigrator, configuration, mappingsAssembly, conventionsAssembly, name_of_script_to_create);
                    break;
                case RoundhousEFluentNHDiffingType.MaintenanceWithRestore:
                    run_maintenance_database_setup(true, databaseMigrator, configuration, mappingsAssembly, conventionsAssembly, name_of_script_to_create);
                    break;
            }
        }