【问题标题】:Pomelo MySql .net core 2 - default execution timeoutPomelo MySql .net core 2 - 默认执行超时
【发布时间】:2020-09-23 21:02:00
【问题描述】:

我们在生产环境中使用 Pomelo MySql 半年了,它工作得很好,但偶尔我们会遇到这样的异常:

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

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

"MySqlConnection": "server=somesql;userid=user;password=pass;database=test;"

没什么特别的。

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

在 DbContext 中执行这样的代码

var timeout = Database.GetCommandTimeout();

总是给我空值。

【问题讨论】:

    标签: mysql .net-core-2.0 pomelo-entityframeworkcore-mysql


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2020-01-17
      • 1970-01-01
      • 1970-01-01
      • 2020-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多