你怎么知道,如果你的迁移是最新与migratordotnet? [英] How do you tell if your migrations are up to date with migratordotnet?

查看:168
本文介绍了你怎么知道,如果你的迁移是最新与migratordotnet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 migratordotnet 来管理我的数据库迁移。我是<一个href="http://stackoverflow.com/questions/868223/migratordotnet-run-migrations-from-within-application-w-o-nant-or-build">running他们在这样的的应用程序的安装,但我也想检查应用程序启动的迁移是最新的,并提供迁移到最新的选项。如何判断是否有需要可应用的迁移?我看到,我可以得到施加这样的迁移

  VAR ASM = Assembly.GetAssembly(typeof运算(Migration_0001));
VAR迁移=新Migrator.Migrator(SqlServer的,setupInfo.DatabaseConnectionString,ASM);
VAR应用= migrator.AppliedMigrations;
 

我喜欢做这样的事情:

  VAR可用= migrator.AvailableMigrations; //这个属性不存在。
 

解决方案

我找到了方法。看着migratordotnet源$ C ​​$ C有助于。

  VAR提供商= ProviderFactory.Create(SqlServer的,myConnectionString);
VAR装载机=新MigrationLoader(供应商,ASM,错误的);
变种availableMigrations = loader.GetAvailableMigrations();
 

I'm using migratordotnet to manage my database migrations. I'm running them on application setup like this, but I would also like to check on application startup that the migrations are up to date, and provide the option to migrate to latest. How do I tell if there are available migrations that need to be applied? I see that I can get the migrations that were applied like this

var asm = Assembly.GetAssembly(typeof(Migration_0001));
var migrator = new Migrator.Migrator("SqlServer", setupInfo.DatabaseConnectionString, asm);
var applied = migrator.AppliedMigrations;

I like to do something like this:

var available = migrator.AvailableMigrations; //this property does not exist.

解决方案

I found the way. Looking at migratordotnet source code helps.

var provider = ProviderFactory.Create("SqlServer", myConnectionString);
var loader = new MigrationLoader(provider, asm, false);
var availableMigrations = loader.GetAvailableMigrations();

这篇关于你怎么知道,如果你的迁移是最新与migratordotnet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆