title: How does .Net binds DBContext to specific database
body: <p>I am learning EF Code first approach and followed this tutorial <a href="http://msdn.microsoft.com/en-US/data/jj193542" rel="nofollow">http://msdn.microsoft.com/en-US/data/jj193542</a>. When the application was run for the first time, it created a database in C:\Users\User123\ directory and added records to Blogs table. Then I commented the code to add records to database and it properly retrieved records.</p>
  
  <p>Then I thought to move the database into a folder under project, so I cut it from C:\Users to a folder named Data in the project, and added a connection string in app.config and used name of connectionstring in BloggingContext constructor like this </p>
  
  <pre><code>public BloggingContext () : base("MyConnection")
  </code></pre>
  
  <p>Here is the connection string:</p>
  
  <pre><code>name="MyConnection"
  
  providerName="System.Data.SqlClient"
  
  connectionString="Data Source=(localdb)\v11.0;AttachDbFileName=|DataDirectory|\MyDB.mdf; Initial Catalog=MyDB;Integrated Security=True;MultipleActiveResultSets=True"
  </code></pre>
  
  <p>But when I ran the application it said failed to connect. So:</p>
  
  <p>Question 1: Is this not a correct connection string?</p>
  
  <p>Then I deleted the database from the project thinking that BloggingContext would re-create the database. But to my surprise, it did not create database this time. However, if I change the db context name from BloggingContext to BloggingContext_New (or some other), it created the database again. </p>
  
  <p>Everytime I put a new name it created a new database, but when I put BloggingContext, it does not create DB. So, I have another question</p>
  
  <p>Question 2: Where does .Net keep association of DBCOntext to DB and is there any way to find/edit or delete this, so that I can re-create a DB with same name as previous one?</p>
  
  <p>Thanks a lot for reading through the long question.</p>