title: How do I decrease the connect timeout with Entity Framework?
body: <p>I want to make a database connection to my SQL Server fail fast. How can I decrease the timeout? I've tried adding <code>Connection Timeout=1</code> in my connection string, however this doesn't seem to make a difference.</p>
  
  <p>With <code>Connection Timeout=500</code>, it takes about 8 min 30 seconds to timeout. This is expected. With <code>Connection Timeout=1</code>, it takes around 40 seconds to timeout which is way longer than expected.</p>
  
  <p>I found the <code>EntityConnection.ConnectionTimeout</code> property but it is read only. Is there anything else I can do to decrease this timeout? Is this an issue with Entity?</p>
  
  <p><strong>UPDATE:</strong> Here is my connect string. It still takes ~40 seconds to timeout.</p>
  
  <pre><code>&lt;add name="KofaxAdminToolsEntities" connectionString="metadata=res://*/DB.Model.KofaxAdminTools.csdl|res://*/DB.Model.KofaxAdminTools.ssdl|res://*/DB.Model.KofaxAdminTools.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MY_DATASOURCE;initial catalog=MY_CATALOG;persist security info=True;user id=MY_USER;password=MY_PASSWORD;MultipleActiveResultSets=True;App=EntityFramework;Connection Timeout=1&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p><strong>UPDATE 2:</strong> So I discovered that the timeout was a <strong>tcp timeout</strong>, not a <strong>sql connect timeout</strong>. If my machine were able to reach the host, @marc_s solution would have worked, however, since I cannot reach that host, the tcp timeout comes into play. Does anyone know how to decrease the tcp timeout for a <code>SqlConnection</code>?</p>