title: How do I stop using ASPNETDB.MDF in LocalDB?
body: <p>I implemented ASP.NET Identity and it automatically created ASPNETDB.MDF and aspnetdb_log.ldf in my App_Data folder. I already have the AspNet tables (i.e., AspNetRoles, AspNetUsers, etc) in my SQL Express instance (which is where all my other tables are sitting). As far as I can see, my application is reading and writing membership and role data from the SQL Express database and not ASPNETDB.MDF.</p>
  
  <p>I have set my connectionString in web.config to:</p>
  
  <pre><code>&lt;add name="DefaultConnection" connectionString="Data Source=MyComputerName\SQLEXPRESS;Initial Catalog=MyDatabaseName;Integrated Security=True" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>However, if I remove ASPNETDB.MDF from App_Data, I get the following error when I login:</p>
  
  <p>Exception Details: System.Data.SqlClient.SqlException: One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files.  If this is an existing database, the file may be corrupted and should be restored from a backup.
  Cannot open user default database. Login failed.
  Login failed for user 'MyComputerName\MyUserName'.
  Log file 'C:\Users\MyProjectName\App_Data\aspnetdb_log.ldf' does not match the primary file.  It may be from a different database or the log may have been rebuilt previously</p>
  
  <p>The error goes away once I add ASPNETDB.MDF back to App_Data. </p>
  
  <p>I have searched all the code in my solution and it makes no reference to ASPNETDB. So why is it still trying to read from it?</p>
  
  <p>I am developing ASP.NET web forms on .Net 4.5. </p>