Bug #67171 Default Command Timeout not applying for EFMySqlCommand
Submitted: 10 Oct 2012 4:26 Modified: 11 Mar 2013 17:46
Reporter: Aaron Clauson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.4.5 & 6.6.3 OS:Windows (Windows 7)
Assigned to: Fernando Gonzalez.Sanchez CPU Architecture:Any
Tags: command-timeout, entity-framework

[10 Oct 2012 4:26] Aaron Clauson
Description:
Specifying the "Default Command Timeout" in a connection string used with the MySQL Entity Framework provider has no effect and the command timeout will always end up being 30s.

How to repeat:
1. Find an EF query that takes longer than 30s to execute and check that it generates a timeout exception without the "Default Command Timeout" parameter in the connection string.

2. Set the "Default Command TImeout" parameter to a high value such as 600 and then re-run the query from step 1. The timeout exception will still be thrown after 30s.

Suggested fix:
The issue appears to be do with the way the MySqlCommand class tracks whether a use has explicitly set the CommandTimeout property. As soon as that property gets set then the "Default Command Timeout" parameter from the connection string will be ignored. When a new EFMySqlCommand object is created the CommandTimeout property is set by something in the EF plumbing and after that it will never be possible for it to get changed by the value in the connection string. It can still be changed by directly setting it programmatically on the command object but that's not always desired.

The fix will be to find a way to distinguish between the EF plumbing setting the CommandTimeout to the default value compared to the application specifically setting the value.
[26 Oct 2012 23:19] Fernando Gonzalez.Sanchez
Confirmed,

So far the workoaround is to explicitely set the command time out for EFMySqlCommand objects thru an assignation:
 ctx.CommandTimeout = xxxx;
where ctx is the EF context class  (derived from ObjectContext in the case of Database First).
[11 Mar 2013 17:46] John Russell
Added to changelog for 6.5.6, 6.6.6: 

Specifying the Default Command Timeout option in a connection string
used with the MySQL Entity Framework provider had no effect. The
command timeout was always 30 seconds.