VS2013 调试器 + 实体框架:“运行时拒绝评估表达式",崩溃 [英] VS2013 Debugger + Entity Framework: "runtime has refused to evaluate the expression", crashes

查看:26
本文介绍了VS2013 调试器 + 实体框架:“运行时拒绝评估表达式",崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在针对命中实时 SQL Server 的代码调试单元测试时,我在 VS2013 Ultimate 调试器中遇到了 Entity Framework 6.0.1 的很多问题.

I'm experiencing a lot of problems with Entity Framework 6.0.1 in the VS2013 Ultimate debugger when debugging into unit tests against code that's hitting a live SQL Server.

无法在调试器中查看包含实体的变量.例如,如果我对 DbContext 执行 LINQ 查询并刷新结果视图以实际执行查询,则结果值为无法评估子级".如果我 ToArray() 它,那么现在变量是实体数组而不是 IQueryable,数组中的每个结果都是无法计算表达式".如果我将该数组中的单个实体值存储到变量中并尝试查看它,我会得到运行时此时拒绝评估表达式."

Variables that contain entities can't be viewed in the debugger. For example, if I execute a LINQ query against my DbContext and refresh the results view to actually execute the query, the Results value is "children could not be evaluated". If I ToArray() it, so now the variable is an array of entities instead of an IQueryable, each result in the array is "Could not evaluate expression". If I store a single entity value from that array to a variable and try to view it, I get "The runtime has refused to evaluate the expression at this time."

经常,在涉及访问实体属性的行中按 F10 会导致 Visual Studio 崩溃.

Frequently, F10'ing through a line that involves access to an entity property causes Visual Studio to crash.

如果我针对模拟的假 DbSet 运行测试,则不会发生这种情况.

This doesn't happen if I'm running the test against a mocked-up fake DbSet.

这是一个已知问题吗?有没有办法解决这个问题?

Is this a known issue? Is there a way to fix this?

推荐答案

我遇到了类似的问题,虽然我还没有理解为什么,请转到 Options -> Debugging -> General -> Use Managed Compatibility Mode - 打开,允许我继续正常调试.

I am having a similar problem and although I'm yet to understand why, turning Options -> Debugging -> General -> Use Managed Compatibility Mode - On, allowed me to continue debugging as normal.

我通过这个博文.

这篇关于VS2013 调试器 + 实体框架:“运行时拒绝评估表达式",崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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