开发者

How to migrate to specific version using Migrator.NET

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="Co开发者_如何学CnnectionString" "D:\Projects\My.Migrations.csproj"


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜