title: ASP.NET ConnectionString AttachDbFilename=|DataDirectory|
body: <p>This is about ConnectionStrings / ASP.NET MVC with Visual Studio 2012 ultimate &amp; SQL Server Express 2012.</p>
  
  <p>Following up with this tutorial here: <a href="http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4" rel="nofollow">http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4</a> I came across an issue with these two connection strings at my web.config:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" 
           connectionString="Data Source=(LocalDb)\v11.0;
                             Initial Catalog=aspnet-MvcMovie-users;
                             Integrated Security=SSPI;
                             AttachDBFilename=|DataDirectory|\aspnet-MvcMovie-users.mdf"
           providerName="System.Data.SqlClient" /&gt;
  
      &lt;add name="MovieDBContext" 
           connectionString="Data Source=(LocalDB)\v11.0;
                             AttachDbFilename=|DataDirectory|\Movies.mdf;
                             Integrated Security=True" 
           providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>the website works fine but I couldn't fingure out why the first db is created in the App_Data folder while the second one is created in "C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA"?! I supposed that both will be created in App_data because both utilize this attribute: AttachDBFilename=|DataDirectory|!</p>
  
  <p>note: the tutorial mentions that it should be in the App_Data &amp; they added a screenshot that shows it there indeed!</p>
  
  <p>I have been looking for an answer and got into the complicity of SQL (I thought User Instances might be the solution) but couldn't reach an answer for this : |</p>
  
  <p>(this might be useful to read about User Instances <a href="http://msdn.microsoft.com/en-us/library/bb264564(v=sql.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb264564(v=sql.90).aspx</a>)</p>
  
  <p>Any ideas are greatly appreciated. Thanks in advance.</p>
  
  <p>Regards</p>