Hi,
I have an apllication that load a table in a list with dbcontext class.
The problem is the connection timeout, this is the error:
Microsoft.Data.SqlClient.SqlException: 'Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.'
The view that load data in sql server have an elapsed time of 9 minutes so how can i increase the timeout in ef core 6?
Thanks to everyone.
Amit MohantyPosted Jun 15, 2023, 11:36 AM
You can increase the timeout for executing queries by configuring the CommandTimeout property of the DbContext class:
Or you can set the CommandTimeout property of the DbContext.Database property:
Tuhin PaulPosted Jun 16, 2023, 2:19 AM
In this code, the YourDbContext class inherits from DbContext and sets the command timeout value in its constructor using the Database.SetCommandTimeout method. You can adjust the timeout value (in seconds) to your desired duration. If you're not using dependency injection or need to set the timeout for a specific database operation, you can use the CommandTimeout property of the DbContext.Database property:
After creating an instance of YourDbContext, we set the CommandTimeout property of the Database property to the desired timeout value before executing the database operation.
Rajkiran SwainPosted Jun 15, 2023, 11:11 AM