Before I write this myself, is there a c# method out there floating around that will create the tables, sprocs, and views that get installed by aspnetregsql?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As far as I know there is no API to do this directly – the
aspnet_regsql.exetool just references script files on disk anyhow.For a head start on how to implement this yourself:
You can manually execute
aspnet_regsql.exeviaProcess.Start.Or you can run the program from the command line, with command line options to dump out the script. Then edit those scripts to be DB agnostic (or don’t – up to you), store those scripts as embedded resources in your application, extract them at runtime, and use a
SqlConnectionandExecuteNonQueryto run those scripts against a database.Here are the command line options for
aspnet_regsql.exe:http://msdn.microsoft.com/en-us/library/ms229862(v=vs.80).aspx
Here’s some code I have used to implement the second option: