Reputation:
Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?
I have changed my web.config's connectin string to
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Kooft.mdf;
User Instance=true;
Integrated Security=True;
Initial Catalog=Kooft;"
providerName="System.Data.SqlClient" />
but every time I using ASP.Net Configuration Tool, it will create another ASPNETDB.mdf file in my App_Data folder.
Upvotes: 3
Views: 1465
Reputation: 2971
Run aspnet_regsql.exe from your Framework 2.0 folder, mine is:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Go through the wizard and choose the database that you wish to add the AspNetDB tables too.
Set the connectionstring to connect to your database e.g. (Anything in square brackets may possibly need changing and the brackets removed.
Update your membership provider section of the web.config and set the following setting to be the connectionstringname from above:
connectionStringName="INSERTCONNNSTRINGNAME"
Then you should be ready to roll. Remember to change the same setting on any role or personalization providers you may have already in the web.config.
Upvotes: 3
Reputation: 26956
First, create a new, empty database in your SQL Express instance.
Then run the aspnet_regsql.exe tool that can be found here:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
This will open a GUI wizard allowing you to select a database server and database to be set up with the default schema for the aspnet providers (membership, profile, roles).
Configure the security on the database appropriately - for best results, you probably want to enable Integrated Security, so ensure that the account the web site is runing under has access to the database, there are a number of Database Roles that are created for you - add your account to the appropriate ones.
Then, in your webconfig, you'd have something like:
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=[ComputerName]\SQLEXPRESS;Initial Catalog=[DatabaseName];Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
The key parts to update there are:
That's certainly how I got mine up and running.
Upvotes: 2