John John
John John

Reputation: 1

How to increase the Timeout session between Entity framework & Sql Server

I am working on an entity framework inside asp.net mvc 5. and the sql server is very slow , so whenever i try to access a page that is connected to the Db i receive the following error:-

Server Error in '/' Application.
--------------------------------------------------------------------------------


The wait operation timed out 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.ComponentModel.Win32Exception: The wait operation timed out

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 

but i can not find a way to increase the timeout inside my entity framework class ? My connection string inside web.config looks as follow:-

<add name="***Entities" connectionString="metadata=res://*/Models.Model2.csdl|res://*/Models.Model2.ssdl|res://*/Models.Model2.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=*******;initial catalog=TMSres;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

How to increase the Timeout session between Entity framework & Sql Server?

Thnaks

Upvotes: 2

Views: 1575

Answers (1)

Anshul Nigam
Anshul Nigam

Reputation: 1628

You can set it by

// Specify a timeout for queries in this context, in seconds.<br>
context.CommandTimeout = 120;

http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.commandtimeout(v=vs.110).aspx

Upvotes: 2

Related Questions