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
LVL 3
joeyluAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dustin HopkinsSenior Web DeveloperCommented:
Try using sql mangmt express to mount your database and then do a regsql.
Then in your web config you need to modify the rolse and membership provider.
Also, the web.config probably created a conn string called: SqlRoleManagerConnection, you need to alter that to point to your database.
I can't remember if IIS7 uses the role provider and membership provider config options but you need to check those to make sure they point to the above connection string.

Another way would just be to transfer the contents of database.mdf over to the file it is creating and point your primary connectionsting to it.

Hope this helps,
Dustin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chrisgreavesCommented:
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
0
Dustin HopkinsSenior Web DeveloperCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.