The ASPNET configuration website utility will create membership and role schema's into a local SQLExpress database, which is wonderful in many cases. This is defined in your machine.config file, and therefore the default behavior. Great! However, there are manual steps that must be taken in order to set up and configure a SQL Server 2005 database.
First steps involve adding a connection string to the SQL Server 2005 database and redirecting the membership and role provider to use that connection string. A three part process:
First, add a custom connection string::
<connectionStrings>
<add name="SqlServer2005" connectionString="data source=MyComputer\SQL2005;Integrated Security=SSPI;Initial Catalog=SomeDatabase;" providerName="System.Data.SqlClient" />
</connectionStrings>
Next, change the providers:
<membership defaultProvider="MMSqlServer2005MembershipProvider">
<providers>
<add
name="SqlServer2005MembershipProvider"
connectionStringName="SqlServer2005"
type="System.Web.Security.SqlMembershipProvider"
/>
</providers>
</membership>roleManager defaultProvider="SqlServer2005RoleProvider" enabled="true" >
<providers>
<add
connectionStringName="SqlServer2005"
name="SqlServer2005RoleProvider"
type="System.Web.Security.SqlRoleProvider"
/>
</providers>
</roleManager>
Piece of cake, makes sense. However, don't go run the ASPNET configuration website utility just yet or you are likely to encounter an error looking something like this:
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'
That's because this object does not exist in the SQL Server 2005 database. This is what threw me for a bit as I assumed the configuration website would create it the same as it does with SQLExpress. Instead, you need to run the aspnet_regsql.exe utility from the framework 2.0 directory. Remember to grant the ASPNET user rights to the SQL Server 2005 database, then run:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
This will bring up a wizard interface that does what we want it to do, however there are a number of command line options that enable advanced functionality.
After the wizard completes the ASPNET configuration website utility in the manor you would expect, then peace and harmony will return to the universe.
Happy Monday!