title: SQL Server 2012 connection string for EF5 Code First
body: <p>I created an MVC4 solution in VS 2012 with EF5, and right now I am trying to get the database to be created Code First. In the <em>Create</em> method of the controller I added <code>db.Database.CreateIfNotExists();</code>
  On my machine, I also have SQL Server 2012 running, and I would like the db to be created there instead of in some SQL Express engine or other lightweight solution.</p>
  
  <p>I have tried several approaches to making a correct connection string, but all has failed, and now I have no idea as to how it should look. This is how it looks now, but nothing gets created, and all i get from the <code>CreateIfNotExists</code> is an error:</p>
  
  <ul>
  <li>InnerException  {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}    System.Exception {System.Data.SqlClient.SqlException}</li>
  </ul>
  
  <p>This is what my connection string looks like:</p>
  
  <p><code>&lt;add name="Tool.Models.Context" connectionString="Server=MSSQLSERVER;Initial Catalog=Tool.models.ToolDb.mdf;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /&gt;</code></p>
  
  <p>EDIT:</p>
  
  <p>After struggling with this issue for almost a day, I resolved it by substituting <code>localhost</code> for <code>MSSQLSERVER</code> (Which still is the name of the instance if I look at the Configuration Manager). Thanks for the comments though. Made me think.</p>