DbMigrator - 详细的代码优先迁移 [英] DbMigrator - verbose code-first migration

查看:388
本文介绍了DbMigrator - 详细的代码优先迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用软件包管理器控制台时,可以运行以下命令:

When using Package Manager Console, you can run the following command:

PM> Update-Database -Verbose

-Verbose switch将所有尝试的SQL命令写入控制台窗口,这对调试非常有用。

The -Verbose switch will write all attempted SQL commands to the console window, which is quite useful for debugging.

您可以使用 DbMigrator 类在代码中执行相同操作:

You can use the DbMigrator class to do the same in code:

Configuration config = new Configuration();
//... (set up the config object)
DbMigrator migrator = new DbMigrator(config);
migrator.Update();

有没有像 -Verbose 开关如果您使用 DbMigrator 类?我看了整个文件,但找不到任何东西。

Is there something like the -Verbose switch if you use the DbMigrator class? I looked all over the documentation, but couldn't find anything.

推荐答案

查看本文是否解决了您的问题:

See if this article solves your problem:

http://whiteknight.github.io/2013/01/26/efcodeonlymigrations.html

简而言之:

MigratorScriptingDecorator scripter = new MigratorScriptingDecorator(migrator);
string script = scripter.ScriptUpdate(null, null);

这篇关于DbMigrator - 详细的代码优先迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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