1

We've got a little console app that creates scripts based on to>from migrations ... we're using to do our rollback scripts as well.

With rollback we stick in null and the migration to rollback to.

We've just moved the Console app to a new solution, but I cannot get it to make the first rollback script when the is only one migration in _MigrationHistory.

Any ideas?

    public static string CreateScriptBetween(string from, string to, string name)
    {
        var dbMigrator = new DbMigrator(new EmptyConfiguration());
        var scriptor = new MigratorScriptingDecorator(dbMigrator);
        var script = "USE MYCOOLSKILLZDB" + Environment.NewLine + Environment.NewLine + "GO" + Environment.NewLine
                    + Environment.NewLine;

        script += scriptor.ScriptUpdate(from, to);
        var filename = FileGenerator.NewNamedFilename(name, "sql");
        using (var writer = new StreamWriter(filename, false))
        {
            writer.Write(script);
        }

        return filename;
    }
Andy Clarke
  • 3,234
  • 5
  • 39
  • 66
  • Try Update-Database -TargetMigration:$InitialDatabase http://stackoverflow.com/questions/10282532/entity-framework-start-over-undo-rollback-all-migrations – Steve Greene Feb 16 '16 at 18:47

0 Answers0