找到了DBUpdateException的原因 [英] Finding the reason for DBUpdateException

查看:1261
本文介绍了找到了DBUpdateException的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用 DbContext.SaveChanges ,我得到一个DbUpdateException:

When calling DbContext.SaveChanges, I get a DbUpdateException:

类型System.Data.Entity.Infrastructure.DbUpdateException的未处理的异常出现在EntityFramework.dll其他信息:。在更新条目时出错详情请参阅内部异常

不幸的是,没有内部异常(至少,不会至于我可以看到)。有没有什么办法,看看究竟为什么的SaveChanges 抛出一个异常?最起码,这将是有益的,看看表的SaveChanges试图与当错误发生更新。

Unfortunately, there is no inner exception (at least, not as far as I can see). Is there any way to see exactly why SaveChanges threw an exception? At the very least, it would be helpful to see what table SaveChanges tried to update with when the error occured.

推荐答案

在它看来,真正的例外丢失的地方,你最好的办法是打破每个异常。不管它是否逮住或吞食的地方​​,或缩小你的范围,调试器将打破,并让你看到发生了什么事情。

When it seems that the real exception gets lost somewhere, your best bet is to break on every exception. Regardless of if it's catched or swallowed somewhere, in or out your reach, the debugger will break and allow you to see what's going on.

有关详细信息,请参阅此MSDN链接:

See this MSDN link for more info:

如何:打破异常时被抛出

这篇关于找到了DBUpdateException的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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