Thursday, December 18, 2008

Integration of Aspnet membership DB with your own DataBase

Open Command Promt and change the directory to your .net 2 framework directory e.g. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. If you use VS 2008, still you have to go to .net 2 directory not 3.5. Then run the following command -

aspnet_regsql -A mr -C "Data Source=localhost;Initial Catalog=targetDB;Integrated Security=true"

Here the assumption is that the target application database will be targetDB.

After executing this command you will find application database will contain 6 additional tables -

aspnet_Applications,
aspnet_Membership,
aspnet_Roles,
aspnet_SchemaVersions,
aspnet_Users and
aspnet_UsersInRoles

These tables will serve aspnet built-in user & role management. Then in config file add the following connection string -

add name="SqlServices" connectionstring="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=targetDB;

If you don't name the connection string as "SqlServices", you have to configure the membership in config file by yourself.

No comments: