I started working today on a solution I had not worked on for a while. It makes use of an ASP.NET web application as a site to host SharePoint webparts (using Typemock to mock out any troublesome calls). The problem I had was that when I opened this VS2010 solution in VS2012 I could not run up this test web site. As the test web pages have WebpartManager controls it needs an ASPNETDB in the AppData folder to persist the settings data. This is usually auto created when SQLExpress is installed, problem is with VS2012 you get the newer LocalDB and I am trying to avoid installing SQLExpress

So the first step was to modify the web.config to point to the right place, by adding


I then loaded the web site but got the error

An error occurred during the execution of the SQL file ‘InstallMembership.sql’. The SQL error number is -2 and the SqlException message is: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

after a retry I saw

An error occurred during the execution of the SQL file ‘InstallCommon.sql’. The SQL error number is 5170 and the SqlException message is: Cannot create file ‘C:PROJECTSSABSSOURCESABSSABSWEBSERVICETESTHARNESSAPP_DATAASPNETDB_TMP.MDF’ because it already exists. Change the file path or the file name, and retry the operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Creating the ASPNETDB_5689a053209d438db3622d593ea632fb database…

So I decided to try the aspnet_regsql.exe in wizard mode from the .NET 4 framework folder to populate a pre-created DB, this gave the same timeout errors as seen when it was run by the web process

So finally I tried the following process

  1. Created a new empty DB in the APPDATA folder attached to my LocalDB instance in SQL Server Object Explorer
  2. From the .NET framework folder loaded and then ran the following SQL scripts (in the order they were listed in the folder)

-–        16/08/2012     12:59      24603 InstallCommon.sql
-–        16/08/2012     12:59      56073 InstallMembership.sql
-–        16/08/2012     12:59      52347 InstallPersistSqlState.sql
-–        16/08/2012     12:59      34950 InstallPersonalization.sql
-–        16/08/2012     12:59      20891 InstallProfile.SQL
-–        16/08/2012     12:59      34264 InstallRoles.sql

  1. Made sure my test harness targeted .NET 4
  2. and my test harness loaded

Not a great solution but it got me working, especially as I could find little on ASPNETDB and LocalDB