Pomelo MySql .net Core 2-默认执行超时

时间:2018-08-07 13:23:32

标签: mysql .net-core-2.0 pomelo

我们已经在生产环境中使用Pomelo MySql半年了,并且效果很好,但有时我们会遇到类似这样的异常:

MySql.Data.MySqlClient.MySqlException: The Command Timeout expired before the operation completed.

appsettings.json中的连接字符串如下:

“ MySqlConnection”:“服务器= somesql;用户标识=用户;密码=密码;数据库=测试;”

所以没有幻想。

我的问题是pomelo中的默认命令执行超时是多少? 如何通过连接字符串更改它?

在DbContext中执行这样的代码

var timeout = Database.GetCommandTimeout();

总是给我空值。

1 个答案:

答案 0 :(得分:0)

尝试通过指定default command timeout来增加连接字符串中的命令超时(以秒为单位)。

在您的情况下,您的连接字符串应如下所示:

server=somesql;userid=user;password=pass;database=test;default command timeout=120;