views:

21

answers:

2

Is it possible to set up ASP.NET application services (membership, profiles, roles etc) for a site without having to run the aspnet_regsql tool directly?

I have managed to create the admin user and roles in session start for the first user that visits the site (the developer), but want to go an extra step before hand and create the tables if they don't exist.

The ultimate idea would be just for the DBA to create a blank database on the server and have the web application itself create all the required tables (if they don't exist).

A: 

Hey,

Why not create the tables/procs on your local database, then generate a script for those tables/procs and give that to your DBA?

No automatic process other than the process that generates the local SQL file (App_Data/ASPNETDB.mdf).

Brian
It's more a nicety than a requirement (since I am a DBA as well), but thought it was possible considering it is done automatically when it is in the App_Data folder (i.e. don't change LocalSqlServer connection string)
Sam
I think it executes aspnet_regsql to do that though, and that process is not customizable; but you may be able to trigger a process using aspnet_regsql in a similar way... easier to just script it though.
Brian
A: 

You can use the script-files located in your .NET Framework installation directory (for example C:\Windows\Microsoft.NET\Framework\v4.0.30319). There are eight Install*.sql files there. Before you run them however, you have to edit them to change the database name.

A more detailed explanation can be found here.

Kristof Claes
Seen those scripts, so could they be loaded (via C#), a find and replace ('aspnetdb' with whatever is the database name - obtained through reflection or otherwise?) and then the resulting string executed? Could there be a timeout though, or should they run pretty quickly?
Sam
Actually, I don't know how quickly they run. I have never used them myself. Only one way to find out :-)
Kristof Claes