DbMigrator - verbose code-first migration

空扰寡人 提交于 2019-12-06 01:00:00

问题


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

PM> Update-Database -Verbose

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

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();

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


回答1:


See if this article solves your problem:

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

In short:

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


来源:https://stackoverflow.com/questions/24357963/dbmigrator-verbose-code-first-migration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!