可以设置EF code首先迁移种子方法中设置断点? [英] Can one set a breakpoint in EF code first migrations seed method?

查看:153
本文介绍了可以设置EF code首先迁移种子方法中设置断点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在种子东西麻烦方法在 Configure.cs 我的实体框架$ 6 C $ C-先迁移过程。我运行的是更新,数据库-verbose 在命令中的软件包管理器控制台,并试图设置断点(以VS在种子方法的C#code工作室网络EX preSS 2013年)。但是,即使我把它放在第一条语句的方法,它是没有命中,虽然控制台显示运行种子法(随后由于打破了我的错误)

I am having trouble with something in the Seed method in the Configure.cs for my entity framework 6 code-first migration process. I am running the Update-Database -verbose command in the Package Manager Console, and tried to set breakpoints (in VS studio web express 2013) in the c# code of the Seed method. But even if I put it on the first statement in the method, it is not hit, although the console displays running seed method (and subsequently breaks due to my error)

种子方法可以这样不知怎地设置断点?如果没有,什么是调试code的最佳方式?

So can one somehow set breakpoints in the Seed method? If not, what is the best way to debug that code?

推荐答案

这是不可能直接内源$ C ​​$ C,但你可以通过附加源$ C ​​$ C调试器。请参阅此链接详情:

It's not possible directly within source code but you can attach the debugger via source code. Please see this link for details:

if (System.Diagnostics.Debugger.IsAttached == false)
   System.Diagnostics.Debugger.Launch();

另一种选择将是通​​过运行源$ C ​​$ C迁移按照上面的说明:

The other option would be to run the migration via source code as explained above:

var configuration = new Configuration();
var migrator = new DbMigrator(configuration);
migrator.Update();

这篇关于可以设置EF code首先迁移种子方法中设置断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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