调试代码优先的实体框架迁移代码 [英] Debug code-first Entity Framework migration codes
问题描述
我首先在我的网站上使用实体框架代码,我只是想知道是否有任何方法可以调试迁移代码.你知道,比如设置断点之类的.
I'm using Entity Framework code first in my website and I'm just wondering if there is any way to debug the migration codes. You know, like setting breakpoints and stuff like this.
我正在使用包管理器控制台使用 Update-Database
更新数据库.
I'm using Package Manager Console to update the database using Update-Database
.
谢谢
推荐答案
我知道 EF Code First Migrations 是相对较新的工具,但不要忘记您仍在使用 .NET.
I know that EF Code First Migrations is relatively new tool but don't forget about you are still in .NET.
所以你可以使用:
if (System.Diagnostics.Debugger.IsAttached == false)
{
System.Diagnostics.Debugger.Launch();
}
之后你可以看到你的 InnerException.
After that you can see your InnerException.
或者你可以像这样使用 try...catch 语句:异常处理实体框架
Or you can use try...catch statement like this: Exception handling Entity Framework
这篇关于调试代码优先的实体框架迁移代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!