In the current project that I am working on we are using Visual Studio 2008. This means that we can make use of LINQ to SQL to access our fairly extensive database schema, and we can manage the development and deployment of that schema using the Database Professional features of Visual Studio Team Suite.
However, I wanted to leverage the significant work already done as part of ASP.NET around user and role management and this meant I needed to find a way to neatly integrate those database creation scripts into the one I built with DB Pro.
I’d be nice if I could “Add Reference” to the ASP.NET database schema so that my database deployment would include it, but its not possible (yet). Instead what I decided to do was use the export feature of the “aspnet_regsql.exe” tool.
aspnet_regsql.exe -S (local) -E -sqlexportonly import.sql -A all -d MyDatabase
This generates a file called import.sql which I then opened and copied to contents of into my Script.PostDeployment.sql file inside the database project. I also trimmed off the database creation and USE logic up the top of the script to make the schema a bit more portable.
Can anyone think of a neater way?