Link to home
Start Free TrialLog in
Avatar of joeylu
joeylu

asked on

sqlexpress with asp.net role & membership

This is my platform for this small website:

IIS7
SQL Express 2008
developed by Visual Studio 2008 web express

And this is how I run my website:

The database is automatically created by visual web studio, as a MDF file inside of App_Data, I named it database.mdf
I upload every files via ftp, include the MDF file, and change the app_data folder writable from Network Services Account
I added following line at web.config:
<add name="iConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True"  providerName="System.Data.SqlClient" />

The website runs smoothly, no problem at all.

The problem came when I start use the Roles & Memberships, the visual web studio express automatically create another database file, named Aspnetdb.mdf, and stores everything about roles and memberships to that database.

My question is: How can get rid of the aspnetdb.mdf, and use my own database.mdf to store Roles and Memberships?

Here are steps I've done and searched, and it's not working.

1.  "aspnet_regsql.exe" is the tools that ppl tell me to use, to make my database.mdf capable to run the Roles and Memberships. Well, when I try to use the aspnet_regsql.exe, it couldn't even find my database.mdf.
2.   I tried manually rename the aspnetdb.mdf, but it doesn't work this way, everytime the website will try to create aspnetdb.mdf by itself, i think i need to modify some line in web.config?

any solution would be helpful, but make sure you understand my develop environment, thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Dustin Hopkins
Dustin Hopkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry I don't have a solution for you but I am curious to know why you do not want Aspnetdb.mdf. It seems to encrypt all the vital info, manage the roles etc, doing all the heavy work for us.
Chris
Chris,
Generally most small to medium websites don't need multiple databases to maintain the user info and website data separately, since it's easier to reference that data whilst in the same database. Also since both databases are running on the same instance of sql, so you wont see much performance gain from seperating the databases.

In Joeys case, it sounds like he had already created his primary database and didn't want .net to create a second one for roles and mem.

So all he needed to do was either attach his mdf to sql, run a regsql, then alter his webconfig to point to his mdf in the provider conn string.
Or copy all of his existing database objects to aspnetdb, then alter his normal connstring to point to the aspnetdb.mdf file.

As for encrypting vital, managing, ect. When you use aspnet_regsql.exe it creates all the tables, views, functions, ect. that are in the aspnetdb on what ever database you specify, basically making it an aspnetdb database.( Easier if you have already created a db and data, but haven't setup roles and providers.)

Hope this helps,
Dustin