开发者

How to migrate to specific version using Migrator.NET

开发者 https://www.devze.com 2023-01-26 18:05 出处:网络
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;

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

精彩评论

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

关注公众号