How to migrate to specific version using Migrator.NET

457 Views Asked by At

Is there any way to rollback to a specific version using Migrator.NET?

I'm running migrations on a SQL Server 2005 database using MSBuild;

"C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" /target:UpdateDb /property:MigrationConnectionString="ConnectionString" "D:\Projects\My.Migrations.csproj"

1

There are 1 best solutions below

0
On

I found my target section (in My.Migrations.csproj) having a property named "To".

  <Target Name="UpdateDb">
    <CreateProperty Condition="'$(To)'==''" value="-1">
      <Output PropertyName="To" TaskParameter="Value">
      </Output>
    </CreateProperty>
    <Migrate Provider="SqlServer" Connectionstring="$(MigrationConnectionString)" Migrations="$(OutputPath)$(AssemblyName).dll" To="$(To)" />
  </Target>

So just by adding /p:To=5 (where 5 is the version number found in SchemaInfo) to the MSBuild run mentioned in the question, I was able to rollback my DB. Hope this helps someone.