MySQL实体框架 - 超时生成模型 [英] Entity Framework with MySQL - Timeout Expired while Generating Model

查看:162
本文介绍了MySQL实体框架 - 超时生成模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MySQL中构建了一个数据库,我试图用Entity Framework映射它,但是当我尝试向EF上下文添加超过20个表时,我开始运行GenerateSSDLException。


类型为
'的异常Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine + GenerateSSDLException'
在尝试从数据库更新
时发生。异常
消息是:'
执行命令定义时发生错误。

$ b

命令执行过程中遇到致命错误。



超时过期。在完成操作或服务器之前经过的超时时间没有响应。


受影响的表没有什么特别的,它是从来没有相同的表,只是在添加了一些(非特定)数目的表之后,如果没有超时过期错误,则不能再更新上下文。有时只剩下一张桌子,有时候是三张桌子。结果相当不可预测。此外,可以在错误之前添加的表的数量的差异向我指出,或许问题在于生成的查询的大小以更新包含现有表定义的上下文以及新表正在添加到它。基本上,SQL查询变得太大,并且由于某种原因而无法执行。



如果我使用 EdmGen2 它没有任何错误,但生成的EDMX文件无法在Visual Studio中更新而不产生上述异常。



很可能这个问题的根源在于Visual Studio中的工具,因为EdmGen2工作正常,但我希望其他人可能就如何处理这个非常独特的问题提供一些建议,因为似乎我不是唯一一个体验它的人



一个同事提出的一个建议是维护两个单独的EBMX文件与一些表交叉,但这似乎是一个非常丑的修复在我看来。我想这是我试图使用新技术的东西。 :(

解决方案

我刚刚在整个下午头痛这个问题,但是我发现你可以添加的解决方案在App.config或web.config中的一个声明,您的EF desinger连接存在默认命令超时= 300000;。问题已经消失。


I've constructed a database in MySQL and I am attempting to map it out with Entity Framework, but I start running into "GenerateSSDLException"s whenever I try to add more than about 20 tables to the EF context.

An exception of type 'Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine+GenerateSSDLException' occurred while attempting to update from the database. The exception message is: 'An error occurred while executing the command definition. See the inner exception for details.'

Fatal error encountered during command execution.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

There's nothing special about the affected tables, and it's never the same table(s), it's just that after a certain (unspecific) number of tables have been added, the context can no longer be updated without the "Timeout expired" error. Sometimes it's only one table left over, and sometimes it's three; results are pretty unpredictable. Furthermore, the variance in the number of tables which can be added before the error indicates to me that perhaps the problem lies in the size of the query being generated to update the context which includes both the existing table definitions, and also the new tables that are being added to it. Essentially, the SQL query is getting too large and it's failing to execute for some reason.

If I generate the model with EdmGen2 it works without any errors, but the generated EDMX file cannot be updated within Visual Studio without producing the aforementioned exception.

In all likelihood the source of this problem lies in the tool within Visual Studio given that EdmGen2 works fine, but I'm hoping that perhaps others could offer some advice on how to approach this very unique issue, because it seems like I'm not the only person experiencing it.

One suggestion a colleague offered was maintaining two separate EBMX files with some table crossover, but that seems like a pretty ugly fix in my opinion. I suppose this is what I get for trying to use "new technology". :(

解决方案

I just had headache on this problem in the whole afternoon. However, I found the solution that you can just add a statement in app.config or web.config where your EF desinger connection exists as 'Default Command Timeout=300000;'. The problem's gone.

这篇关于MySQL实体框架 - 超时生成模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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