1
votes

I have following connection string:

metadata=res:///Database.csdl|res:///Database.ssdl|res://*/Database.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename='Database.mdf';Integrated Security=True;User Instance=True;Connection Timeout=300;"

I expect that this connection string can never get timeout (because it is 5 mins). However, on a very easy database.table.Count() call to Entity Framework it fails in 10 seconds with "Timeout" exception. Why does Entity Framework ignores SQL timeout? How to set timeout for Entity Framework?

2
possible duplicate of Entity Framework TimeoutsMatt

2 Answers

3
votes

Connection timeout specifies the amount of time to spend waiting for a connection. It doesn't affect the amount of time that a query can spend before timing out.

For that, you need to search for a CommandTimeout property on whatever database context class you're using.

0
votes

Connection Timeout is the amount of time to wait whilst attempting to connect to the DB server not executing a query