Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
possible duplicate of Set database timeout in Entity Framework –  usr Jun 22 at 14:20
add comment

1 Answer

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

NOTE: Please mark this as answer and vote it up if this was helpful :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.