What is the default timeout for EF queries? I've tried to find out by checking context.CommandTimeout
, but it returns null
.
I have also looked in the web config in the connection string for something like Connect Timeout=
, but it doesn't seem to be there by default.
Sometimes, however, you might also want to include a task that requires longer than the default command timeout value (30 seconds in SQL Server) such as importing a lot of data.
The time in seconds to wait for the command to execute. The default is 30 seconds.
You can use DbContext. Database. CommandTimeout = 180; It's pretty simple and no cast required.
The CommandTimeout property sets or returns the number of seconds to wait while attempting to execute a command, before canceling the attempt and generate an error.
The default timeout for object queries and the SaveChanges operation is defined by the underlying connection provider. Since Entity Framework can be used for many connection providers, mysql, sql server etc. and all have different default timeout's!
So null
means default timeout will be used, if you want to know what is the default then it depends on the connection provider you are using!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With