Monday, January 28, 2013

VS - VS 2010 Database Project: An Introduction


Visual Studio 2010 has a new Database Project. The scripts in this new Database project define your database just like the files in your code projects define your application.
The prior Database project (the one under the "Other Projects" node in VS 2003/2005/2008 as detailed in this prior post), was simply a storage container for your database scripts.
The new Database project is alive. Like the old Database project, it retains your database scripts, but it also has Intellisense, build-time validation, and automatic deployment features. It allows you to keep the definition of the database in your scripts and ensure that the scripts are deployed to your development database.
This is the first in a series of posts on using the new Database project. This post provides the steps for adding a Database Project to any solution in either VB or C#.
1. Right-click on your solution and select Add | New Project. Or select File | New Project from the main menu.
The Add New Project dialog is then displayed.
image
2. Open the Database node in the Installed Templates panel on the left and select SQL Server.
3. Select SQL Server 2008 Database Project from the middle panel, enter a name for the project, and click OK.
NOTE: If you have SQL Server 2005, you can select the SQL Server 2005 Database Project instead.
Visual Studio then creates the new project and adds it to your Solution Explorer:
image
4. Use the Database project to write the scripts for a new database or manage the scripts for an existing database.
For example, use the Tables node to manage your table scripts and the Programmability | Stored Procedures node to manage your stored procedure scripts:
image

No comments:

Post a Comment