找到了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:

如何:打破异常时被抛出