Learn Membership Services Part 1: Installing ASP.NET Membership Services Database in SQL Server 2008

Introduction

We create a website or web application with a login page, user panel, admin panel, etc. We do a lot of code and queries to register a user and to validate a user for login in their panel. To reduce code or almost remove code for login/register from the application/website, the membership feature comes in ASP.NET.

The membership feature provides an abstraction for the underlying data store that maintains user credentials, such as user names and passwords. It provides an API allowing you to validate user credentials and manage the database easily. ASP.NET supports SQL Server and Active Directory providers. We can also create our providers for custom stores.

This article explains

  1. How to create a database using SQL Server Management Studio
  2. How to install an ASP.NET Membership Services Database in SQL Server

Installing ASP.NET Membership Services database in SQL Server

We will go through how to create a database in SQL Server 2008 using SQL Server Management Studio and then install ASP.NET membership services. So let's see that now.

  1. Right-click on the "Database" folder, then click "New Database."

    image1.png

  2. Open a new Database window. Click on "General," then provide a Database name, then click "OK."

    image2.png

  3. Now we will see our EmployeeDB database successfully created.

    image3.png

Installing ASP.NET Memberships Services Database in EmployeeDB Database

Before going to install ASP.Net membership, we need to know about aspnet_regsql.exe. The ASP.NET SQL Server Registration Tool (aspnet_regsql.exe) creates a Microsoft SQL Server database for the SQL Server providers, roles, and profiles in ASP.NET or to add or remove options from an existing database.

We can run Aspnet_regsql.exe without any command-line arguments to run a wizard, which will be explained in this article. We are installing or removing the database elements for the membership, role management, profile, Web Parts personalization, and health monitoring feature using a wizard but aren't covering the settings for session state and SQL cache dependency by the wizard. Using the options, we can also run Aspnet_regsql.exe as a command-line tool to specify database elements for individual features to add or remove.

  1. Go to "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" and click on aspnet_regsql.exe.

    image4.png

  2. The ASP.NET Server Setup Wizards starts; click the "Next" button.

    image5.png

  3. Check the radio button for "Configure SQL Server for application services" and click "Next."

    image6.png

  4. Use "SQL Authentication" and insert credentials for SQL Authentication and select the database to install ASP.Net services, then click on the "Next" button.

    image7.png

  5. Check to confirm the settings; if the settings are OK, then click on "Next" elsewhere, and click on "Previous."

    image8.png

  6. The database has been modified; click on "Finish."

    image9.png

  7. Go to SQL Server Management Studio and expand the EmployeeDB database, then check the ASP.Net membership tables and views by expanding the "Tables and Views" folder in the EmployeeDB database.

    image10.png

Similarly, we can look at the Stored Procedures by expanding the stored procedure folder. So using this process, we can ensure that the ASP.Net membership tables, views, and Stored Procedures are created, and our database is ready to use ASP.Net membership API.

In the next article, learn about Membership Services in Part 2. I will cover the following points

  1. How to test this with the application.
  2. How to create users.
  3. How to implement form authentication using the membership.


Similar Articles