title: Connection string in unit test project to reference database in app_data folder
body: <p>I am looking to reference my database file in my unit test project. This is an ASP.NET MVC app.</p>
  
  <p>Please note: I know I should not be accessing the database in my unit tests but this is for a quick fix on one test that I need to have pass just now.</p>
  
  <p>After the next milestone I will be mocking the database access methods etc.</p>
  
  <p>So here is my connection string in my mvc app web config and the unit test ap.config files</p>
  
  <pre><code>&lt;add name="DBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DB.MDF;Integrated Security=True;User Instance=True"
    providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>When I run the test I get an error:</p>
  
  <pre><code>Test method
  ED.Tests.Controllers.CandidateControllerTest.PersonalDetailsStepPostShouldRedisplayIfNoSurnameSupplied 
  threw exception:  System.Data.SqlClient.SqlException: 
  An attempt to attach an auto-named database for file C:\Users\Desktop\ED\TestResults\LAPTOP-D 2009-07-22 18_16_20\Out\DB.MDF failed. 
  A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
  </code></pre>
  
  <p>It seems to me the connection string is wrong but I'm not sure how to set the path properly. I have tried adding \..\.. and the directory names etc.</p>