【问题标题】:ADO.Net Entity framework, Fatal error encountered during data readADO.Net 实体框架,读取数据时遇到致命错误
【发布时间】:2012-10-18 03:26:14
【问题描述】:

在将 MySql 与 Entity 框架一起使用时出现以下错误。我在 EntityConnectionStringBuilder 的连接字符串上将默认连接超时设置为 300000。如何在实体框架中解决这个问题?

    Unhandled Exception: System.Data.EntityCommandExecutionException: An    
    error occurred while reading from the store provider's data reader. See the  
    inner exception for details. ---> MySql.Data.MySqlClient.MySqlException: Fatal 
    error encountered during data read. ---> MySql.Data.MySqlClient.MySqlException: 
    Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted 
    to read past the end of the stream.

更新:我们如何为 ado.net 实体框架设置 net_read_timeout?

【问题讨论】:

    标签: c# mysql entity-framework mysql-connector


    【解决方案1】:

    像这样

    data.Database.ExecuteSqlCommand("set net_write_timeout=99999; set net_read_timeout=99999");
    

    【讨论】:

    • 很高兴这对您有所帮助。
    • +1 这太神奇了。这感觉就像一个超级黑客魔法,但它似乎是目前唯一的解决方案。 (在我的例子中,它在一个空表的简单选择查询中抛出了这个错误,所以是的......)
    【解决方案2】:

    内部异常说明了什么?

    未处理的异常:System.Data.EntityCommandExecutionException 不指向超时错误,它可能是简单的 int,需要在您的 EF 查询中为空。

    你能把查询发给吗?

    干杯

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 2011-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多