Set Command Timeout in entity framework 4.3

Saher Ahwal picture Saher Ahwal · Jul 31, 2012 · Viewed 33.8k times · Source

I cannot find the a way to set the command timeout of a linq query using entity framework 4.3 and its' DbContext. How do I increase Commandtimeout in entity framework?

EDIT I am actually looking for Command Timeout increase. I confused the two, it is the sql command that is timing out not the connection.

Thanks

Answer

bricelam picture bricelam · Jul 31, 2012

If you're using DbContext, you'll first need to drop down to ObjectContext:

((IObjectContextAdapter)context).ObjectContext.CommandTimeout = 180;