title: How to explicitly name the database when using Entity Framework Migrations 4.3
body: <p>I've recently started using Entity Framework migrations and noticed that the database name is not pulling through for me when I run the <code>Update-Database</code> command.</p>
  
  <p>My connectionstring is:</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="DataContext" connectionString="Server=.\SQLEXPRESS;Initial Catalog=TestDB;Trusted_Connection=Yes;" providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>The very first time I run <em>Update-Database</em> my database is created with the correct name <em>TestDB</em>. However, as soon as I make a change to one of my entities it will not update any longer for me unless I add a Start Up Project Name (I'm using a multi project solution):</p>
  
  <pre><code>Update-Database -StartUpProjectName "TestDB.Data"
  </code></pre>
  
  <p>This then makes another new database which migrations will always continue to use. I don't mind having to put in the <em>StartUpProjectName</em> command but is there a way to override the default name for the database this produces? It always creates the database as</p>
  
  <pre><code>TestDB.Data.DataContext
  </code></pre>
  
  <p>Is there a way to ensure that the database created when passing the StartUpProject name is just called <em>TestDB</em> or is this a limitation of using the StartUpProjectName setting?</p>
  
  <p>As a note, I think the reason I need to specify the StartUpProjectName is that I have a multilayer project setup. The Migrations Configuration file is in my 'Data' project, the entities/models are in my 'Domain' project, etc. I also do not currently have any initialize options in my Global.asax.cs file as I would have used previously on code first ef 4.2. So in my project I just have a DataContext in my Data project and the Migrations Configuration in that project also.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Since I originally setup this question I stumbled onto the 'correct' way to name a database in a multiproject solution. While the answer below will work it does mean you are duplicating your web.config in another area which isn't an ideal solution. Instead you can just put the name into your DbContext by doing something like this (DataContext is just the name I used in my project):</p>
  
  <pre><code>public class DataContext : DbContext
  {
      public DataContext() : base("DatabaseNameHere")
      { }
  
      public DbSet&lt;Table1&gt; Table1 { get; set; }
      public DbSet&lt;Table2&gt; Table2 { get; set; }
  
      public virtual void Commit()
      {
          base.SaveChanges();
      }
  }
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>Rich</p>