views:

1130

answers:

5

I am building an ASP.NET 3.5 (C#) application and I plan to use the membership and roles security.

I want to set this up on my SQL Server 2008 standard edition and not the default express setting.

How would I go about this?

+2  A: 

you need to run aspnet_regsql. That will popup the wizard to configure your new database.

Joshua Belden
Then make sure to change your web.config file to point to the new server ;)
Nick DeVore
A: 
  1. Take the MDF and LDF files created by Express Edition (usually in App_Data) and Attach them to your SQL Server 2008 Instance.
  2. Setup security for the new database (i.e. add a user to the database that will access the database. Make sure to give the appropriate permissions to the user)
  3. Change the connection string in your web.config to point to the new database

Edit: My answer assumes that you're already using your database and just want to migrate it from SQL Express to SQL Standard edition.

Keltex
If I plan to have more than one web site on the server using membership and roles will this mean all of these users sit in the aspnetdb? Will this then mean anyone registered with this site is already registered with all other web sites? Should I script these dbs instead and then create all tables and sps in my main system db?
littlechris
+2  A: 

You can install membership database with this command aspnet_regsql.exe at *C:\Windows\Microsoft.NET\Framework\v2.0.50727* (adjust to your path)

You can find more details here

NinethSense
Just calling aspnet_regsql with no parameters will start it in "Wizard mode" with a GUI to guide you through picking a database server, database, etc.
Zhaph - Ben Duguid
Yes it is correct.
NinethSense
+2  A: 

It doesn't matter wich database server version you are using for the ASP.NET security membership/role module, apart from being SQL Server.

To set up manually this security on a server you have to run these scripts:

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallCommon.sql

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallMembership.sql

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallRoles.sql

and configure web.config accordingly (see http://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx).

You may run this scripts using the same database where you have your data, or you can create a new database to store user membership or role related data and run them there.

eKek0
If I later decide to use Personalization do I then just run the InstallPersonalization.Sql and the InstallProfile.SQL files on the db too?Also, these are the 2.0 framework files, I take it that since 3.5 is just an expansion of the 2.0 framework these scripts still apply?
littlechris
Also, If I plan to have more than one web site on the server using membership and roles will this mean all of these users sit in the aspnetdb? Will this then mean anyone registered with this site is already registered with all other web sites? Should I change these scripts to create all tables and sps in my main system db?
littlechris
a) I have never installed personalization, but as far as I know what asp.net_regsql does is run this scripts for you, son you can try... I think that running InstallPersonalization.sql and InstallProfile.sql manually will do what you want. And yes, those scripts apply to any SQL Server version greater than SQL 2K (.net version doesn't matter here, either).
eKek0
If you plan to have more than 1 site, each one with a backend database, and share users between them, then you must have a common 'security' database where you store users, roles, etc. and configure each web.config (for each site) to point this 'security' database. You shouldn't use the system database, you must use one of your own. You can configure which changing 'aspnetdb' in the line SET @dbname = N'aspnetdb'.
eKek0
Appreciate the answers and all the advice given. One last thing (promise!), if i wanted each site to have its own unique users and roles could I create them in my application database? Or would it be bad practise?
littlechris
I've updated my answer in response to your question, but in short: yes, you can use your app db
eKek0
A: 

What if I'm using MySQL database and not SQL server? What do I need to run then??

SweeT EviL