Creating a script for ASP.NET membership table structure

5.9k views Asked by At

I'm creating an AppHarbor MVC3 application and want to use the standard membership provider support. The AppHarbor guys told me I needed to create script for the table structure that I can run on my AppHarbor database. I'm not really familiar with databases, however. How do I go about creating and executing a script for the default membership tables?

2

There are 2 answers

6
Shan Plourde On BEST ANSWER

Use the command line aspnet_regsql.exe. See http://msdn.microsoft.com/en-us/library/ff648345.aspx. Excerpt:

Step 2. Install the Membership Database

Before you can use the SqlMembershipProvider, you must install the SQL Server membership database.

To install the membership database, log on to your server with an account that has authority to administrate SQL Server (such as the Administrator account). Open the Visual Studio 2005 command prompt, and run the following command:

aspnet_regsql.exe -E -S localhost -A m

Where:

-E indicates authenticate using the Windows credentials of the currently logged on user. -S (server) indicates the name of the server where the database will be installed or is already installed. -A m indicates add membership support. This creates the tables and stored procedures required by the membership provider. Note The Aspnet_regsql tool is also used to install database elements for other ASP.NET 2.0 features, such as Role Management, Profile, Web Parts Personalization, and Web Events. Other command-line arguments perform database operations for these other features. You can use Aspnet_regsql without any command line arguments by using a wizard that allows you to specify connection information for your SQL Server and install or remove the database elements for all of the supported features.

1
Shabnam On

There is a great article here: http://www.nashcoding.com/2011/02/05/using-the-forms-authentication-membership-provider-on-appharbor/comment-page-1/#comment-477

1.Start a Visual Studio command prompt by going to Start -> All Programs -> Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt.

2.Run the following command, using the your AppHarbor database settings to fill in the values in brackets: aspnet_regsql.exe -S [Host] -d [Name] -U [Username] -P [Password] -A all

3.In your MVC project, open your Web.config file.

4.Replace the connectionString for ApplicationServices with the connection string found on your AppHarbor database page.