title: Entity Framework code-first targeting LocalDb instead of local SQL Server Express host
body: <p>In a new development project using Entity Framework 6.0 code-first I had to update my models quite a bit. The update script that was automatically generated using <code>Add-Migration</code> in Package Manager Console got quite complex so I decided to start over. To do this I deleted the database from localhost and deleted the <code>Migrations</code> folder in the project. However when I re-ran the <code>Add-Migration</code>-command I got the following message and the same update-script was generated again:</p>
  
  <blockquote>
    <p>The Designer Code for this migration file includes a snapshot of your
    current Code First model. This snapshot is used to calculate the
    changes to your model when you scaffold the next migration.</p>
  </blockquote>
  
  <p>I was fairly certain this was because <code>__MigrationHistory</code>-table was still there somehow. I went into the database again but nothing had been created and the database was still gone. </p>
  
  <p>Connection string used in <code>web.config</code>:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" 
           connectionString="Data Source=localhost;Initial Catalog=WebApp;Integrated Security=sspi;Pooling=false;" 
           providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>I then checked my processes and saw two versions of the <code>sqlservr.exe</code>-process and LocalDb came to mind. I connected to <code>(LocalDb)\MSSQLLocalDB</code> and there was a new database named 'DefaultConnection' with all tables for the project. When I deleted this database I got a fresh script from the <code>Add-Migration</code>-command. Somewhere along the line a switch must have been made since I'm 100% certain I have been working against the SQL Server Express host at some time (All tables prior to the update script where there when I deleted the database) and for all my other project localhost works with <code>Data Source=localhost</code>. I can't understand why the database name is <code>DefaultConnection</code> instead of <code>WebApp</code> either. Connecting to localhost, the database name was <code>WebApp</code>. Has anyone experienced this before? </p>
  
  <p><a href="https://i.stack.imgur.com/WayM1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WayM1.png" alt="enter image description here"></a></p>