One of the least documented features in ASP.NET is the way to move the user access and profiles tables in aspnetdb.mdf to a production SQL Server. Although aspnetdb.mdf can be used in production, it is not recommended. This is done in 2 steps, first create the structure (tables, views and stored procedures) in the database, and second point the connection strings in the solution to that database.

The structure should be created automatically, to do so open the command line by opening the Run dialog box and enter cmd. Then change to the directory C:\Windows\Microsoft.NET\Framework\v2.0.50727. Note that the last directory's name may be different, just make sure it's v2.0, which signifies version 2.0 of the .NET Framework. In this directory run the executable called aspnet_regsql.exe. When run without arguments a wizard will start. Although I never had trouble with this tool before, I would still advice to backup the database before continuing the wizard, if its not empty. The following screens show the input pages of the wizard:

The Welcome Screen of aspnet_regsql

Select the Action to Perform

Select the Database


To let the solution use the database for user access and profiles, a hidden connection string called LocalSqlServer has to be removed and added again with the new settings. The following code example does that.

    <connectionStrings>

        <!-- Previously defined connection strings will be here -->        

        <!-- LocalSqlServer is the connectionstring used by the asp.net -->
        <!-- access and profile modules -->
        <remove name="LocalSqlServer"></remove>
        <add name="LocalSqlServer"
            connectionString="Data Source=amgadhs;
                              Initial Catalog=testdb;
                              User ID=amgad;
                              Password=123"
            providerName="System.Data.SqlClient">
        </add>
    </connectionStrings>