Creating a Custom Profile Provider Database in ASP.NET

Creating a Custom Profile Provider Database in ASP.NET

 

ASP.NET 2.0 and later versions make use of the membership provider model. In this model, a default profile provider is made available for developers. This default profile provider is quite sufficient to work with, however, there may sometimes arise a need for a custom profile provider based on your specific requirements.  You can register a new profile provider one by using the command line tool, aspnet_regsql.exe.

 

This tool, when executed at the command prompt, opens a dialog box and uses a wizard-like mechanism that enables you to configure membership services for first time use, modify an existing profile provider, or specify a custom provider.

 

If you specify the name of a database server and the name of a new database, the tool automatically creates a database that looks identical to the standard aspnetdb database, having tables such as Profile, Users and Roles.

 

Assume that you have created a database named customaspdb.

 

This new database can then be used as your profile provider by referring to it within your web.config file as shown below:

 

<connectionStrings>

    <remove name="LocalSqlServer"/>

    <add name="LocalSqlServer"

         connectionString="Data Source=Test;Initial Catalog=customaspdb;Integrated Security=SSPI;"

      providerName="System.Data.SqlClient"/>

  </connectionStrings>