Earlier this month I discovered the new project type “SQL Server 2008 Database Project” in my Visual Studio 2010 Ultimate installation – described in this blog post. Off course I was excited because I had a way of generating my databases from scratch with schema and configuration data for the different configurations, but this solution is not out-of-box as this new project type.
If you want to explore how this project type works, you can import a full database script into your project and getting a quick start. To generate a script for you database, this is one way of doing it:
- Open SQL Server Management Studio (SSMS)
- Right-click the database you want to create script for importing to Visual Studio Database project
- Select “Tasks | Generate Script” from the context menu
- Select “Script entire database and all database objects”
- See my standard scripting settings from the screenshoots below.
I normally just script to file, in case the database is big and too hard to handle in memory. As seen from the advanced options, I set the SSMS to script both schema and data. This done to be able to script basic configuration data to be handled in development, test and production scenarios.
DB scripting options
It’s a good thing to go over the advanced scripting options, its possible to add too much information in the scripts that makes your live harder. Keep it Simple Stupid – KISS.
Advanced DB scripting options
This blog is based on the AdventureWorks database. This can be downloaded from “AdventureWorks Sample Databases“. I have exported the AW database and you might download the complete script here.
The next step is to create a new Visual Studio 2010 Ultimate and import the script that is created in SSMS. Create the new project according to my post. When the solution/project is created, then right-click on the DB project, and choose “Import” as shown in the screenshoot below.
Follow the instructions in the import wizard.
Ooobs!…. The AdventureWorks database script is 500MB, so the import might take some time. But for the lazy of you, here is the full VS2010 project with the final, imported AdventureWorks.
This has to be enough for today….explore the AdventureWorks project and I will come back with more.