title: Correct app.config connection string for application using LocalDb and DbContext?
body: <p>I have a Windows Forms application that uses LocalDb and DbContext.  This works fine on my development box but I have not been able to get it to work when deployed to another box.</p>
  
  <p>In my app.config, I instantiate a named LocalDb instance in  with:</p>
  
  <pre><code>  &lt;system.data.localdb&gt;
      &lt;localdbinstances&gt;
        &lt;add name="LocalProvergience" version="11.0" /&gt;
      &lt;/localdbinstances&gt;
    &lt;/system.data.localdb&gt;
  </code></pre>
  
  <p>My connection string in  is:</p>
  
  <pre><code>&lt;add name="LocalProvergienceEntities"
           connectionString="metadata=res://*/ProvergienceModel.csdl|
                                      res://*/ProvergienceModel.ssdl|
                                      res://*/ProvergienceModel.msl;
                                      provider=System.Data.SqlClient;
                                      provider connection string=&amp;quot;data source=(localdb)\LocalProvergience;
                                      initial catalog=LocalProvergience;integrated security=True;
                                      multipleactiveresultsets=True;
                                      App=EntityFramework&amp;quot;"
           providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>If I include:</p>
  
  <pre><code>   AttachDbFilename=|DataDirectory|\LocalProvergience.mdf;
  </code></pre>
  
  <p>in the connection string, I get an "Invald key value for attachdbfilename" error.  </p>
  
  <p>If I exclude AttachDbFilename, I get "A network-related or instance-specific error occurred while establishing a connection to a SQL server" error.</p>
  
  <p>Several questions:</p>
  
  <ol>
  <li><p>The providerName is set to "System.Data.EntityClient" should this be "System.Data.LocalDb"?</p>
  
  <ol>
  <li>Would anyone be able to post or direct me to an example of a correct app.config for LocalDb and DbContext?</li>
  </ol></li>
  </ol>