title: Connection string not found with ASP.net
body: <p>I'm trying to get my local SQL database connecting to my ASP.Net project and nothing I try is working.
  The database is named cinemaDatabase and its using windows authentication. </p>
  
  <p>In web.config I have </p>
  
  <pre><code>   &lt;connectionStrings&gt;
      &lt;add name="myDatabase" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=cinemaDatabase;Integrated Security=True;" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Then in a cshtml page I have </p>
  
  <pre><code>@using WebMatrix.Data;
  
  @{
      var db = Database.Open("myDatabase");
   }
  </code></pre>
  
  <p>I keep getting this error</p>
  
  <blockquote>
    <p>InvalidOperationException: Connection string "myDatabase" was not
    found. OpenNamedConnection</p>
  </blockquote>
  
  <p>What am I doing wrong here? Thanks in advance.</p>
  
  <p>Edit - 
  Got it working, had to make a normal SQL server instead of the local MSSQLLocalDB one and change the data source in web.config to that.  </p>
  
  <p>Then used this code on my page and it connects now.</p>
  
  <pre><code>@using WebMatrix.Data; 
  @using System.Data.SqlClient; 
  
  @{ 
  
      var connectionString = "Data Source=DESKTOP-58NGNQP;Initial Catalog=webDev;Integrated Security=True";
      var providerName = "System.Data.SqlClient";
      var db = Database.OpenConnectionString(connectionString, providerName);
  }
  </code></pre>