Set Command Timeout in entity framework 4.3
If you’re using DbContext, you’ll first need to drop down to ObjectContext: ((IObjectContextAdapter)context).ObjectContext.CommandTimeout = 180;
If you’re using DbContext, you’ll first need to drop down to ObjectContext: ((IObjectContextAdapter)context).ObjectContext.CommandTimeout = 180;
It will work with your method. Or subclass it (from msdn forum) public class YourContext : DbContext { public YourContext() : base(“YourConnectionString”) { // Get the ObjectContext related to this DbContext var objectContext = (this as IObjectContextAdapter).ObjectContext; // Sets the command timeout for all the commands objectContext.CommandTimeout = 120; } }