DbMigrator - 详细code-第一迁移 [英] DbMigrator - verbose code-first migration

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

问题描述

在使用程序包管理器控制台,您可以运行下面的命令:

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

PM> Update-Database -Verbose

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

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

您可以使用 DbMigrator 类在code做相同的:

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/ 1月26日/ EF codeonlymigrations.html

在短期:

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

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

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