title: Entity Framework Code First and Connection Strings
body: <p>I have a small MVC 3 app using Entity Framework Code First and use this connection string for the model:</p>
  
  <pre><code>data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Journal.mdf;User Instance=true;Database=MyJournal
  </code></pre>
  
  <p>When I make a change to the model (e.g. add a property), I get as expected</p>
  
  <blockquote>
    <p>The model backing the 'JournalContext' context has changed since the database was created.</p>
  </blockquote>
  
  <p>So, being in development mode, I go ahead and delete Journal.mdf and Journal.ldf.</p>
  
  <p>Now when I run the application again, I get </p>
  
  <blockquote>
    <p>Cannot open database "MyJournal" requested by the login. The login
    failed.</p>
  </blockquote>
  
  <p>If I change my connection string to </p>
  
  <pre><code>data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Journal.mdf;User Instance=true;Database=MyJournal2
  </code></pre>
  
  <p>(changed the <code>Database=</code> parameter by appending '2')</p>
  
  <p>Journal.mdf is created and the app works again.  If I make a number of changes and attempt to "recycle" any Database name again, I get the "Cannot open" error.</p>
  
  <p>Why do I need to provide a unique Database name each time I change the model, and how can I "clean out" previous names?</p>