2012-08-22 56 views
0

在使用MySql與實體框架時出現以下錯誤。我在EntityConnectionStringBuilder的連接字符串上將默認連接超時設置爲300000。如何在Entity框架中解決這個問題?ADO.Net實體框架,數據讀取期間遇到致命錯誤

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?

回答

2

像這樣

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

我很高興這對你有幫助。 – Chazt3n

+0

+1這是神奇的。這感覺就像一個超級黑客魔法,但它似乎是現在唯一的解決方案。 (在我的情況下,它是拋出一個空表的簡單選擇查詢的錯誤,所以是的...) – SimpleVar

0

內部例外說什麼?

未處理的異常:System.Data.EntityCommandExecutionException並未指向超時錯誤,它可能與您的EF查詢中需要使用的可爲空的int類似。

你可以給查詢嗎?

乾杯

+0

這是在MySQL中的錯誤從我擡頭http://bugs.mysql.com/bug.php?id=57365,其因超時 – remo

+0

你曾經解決過這個問題嗎?我有相同的場景 – Chazt3n

+0

似乎這是一個在連接器寫入超時的問題...請參閱http://stackoverflow.com/questions/6281304/attempted-to-read-past-end-of -stream-error-in-mysql –