在MySql中使用Entity Framework 6时C#中的错误

时间:2019-06-18 13:15:16

标签: c# mysql .net entity-framework entity-framework-6

我在Windows服务中使用C#将EF6与MySql一起使用。在进入数据库的每个特定数量的条目后,我都面临异常。另外,如果我重新启动MySql Service,则对于某些数量的条目,它将再次正常工作。

我正在使用MySql 6.10.8.0作为MySql数据提供程序驱动程序。另外,我正在使用MySql 5.7.22作为MySQL服务器和MySql Connector Net 8.0.12。

这是我在配置文件中的DBProvider。

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add description=".Net Framework Data Provider for MySQL" invariant="MySql.Data.MySqlClient" name="MySQL Data Provider" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

这给了我这个例外。

System.Data.Entity.Core.EntityCommandExecutionException:发生错误 在执行命令定义时。

MySql.Data.MySqlClient.MySqlException: Fatal error encountered attempting to read the resultset. ---> MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

0 个答案:

没有答案