Walkthrough: Put an Existing Database Schema Under Version Control
In this walkthrough, you learn how to put an existing database under source control, which consists of the following steps:
You create a database project.
You connect to an existing database.
You import the database schema from the existing database into the database project.
You review the results that are shown in the database project.
You put the database project and its contents under version control.
This walkthrough assumes that you have installed a copy of the sample Northwind database on a database server that is running Microsoft SQL Server 2000. You must also have read/write permission to a version control system such as Visual Studio Team System Team Foundation Server or Microsoft Visual SourceSafe.
To create a database project
On the File menu, point to New, and then click Project.
The New Project dialog box appears.
In the Project Types list, expand the Database Projects node, and click SQL Server 2000.
In the Templates list, click SQL Server 2000 Database Project.
In Name, type MyNorthwind, and accept the default values for Location and Solution Name.
Select the Create directory for solution check box if it is not selected by default, and click OK.
A solution is created that contains the MyNorthwind empty database project.
Next, you will start the Import Database Schema process, in which you specify a connection string to the source database.
To import the database schema from the existing Northwind database
In Solution Explorer, click the MyNorthwind project node.
On the Project menu, click Import Database Objects and Settings.
You can also right-click MyNorthwind and click Import Database Objects and Settings.
The Import Database Schema dialog box appears.
In the Source Database list, click the connection that corresponds to your existing Northwind database. If you have not yet connected to that database, you must first create a connection to it. For more information, see How to: Create a Database Connection.
As the schema is imported, project items that correspond to the objects that are in the database appear under the database project in Solution Explorer. Schema View shows the objects that are defined in the database project. You can review the import results on the Summary page before you continue.
Next, you will explore the contents of the database project before you put it under version control.
To examine the results of importing the database schema
On the View menu, click Database Schema View.
Schema View appears if it was not already visible.
In Schema View, expand the node for the database project, and then expand the Tables folder.
The tables in the database project should match the tables in the database.
Right-click the dbo.Employees table in the Tables subfolder, and click Open.
The Transact-SQL editor appears and shows the definition for the dbo.Employees table.
Expand the dbo.Employees object, and expand the Constraints folder within dbo.Employees.
Right-click the CK_BirthDate constraint in Schema View, and click Open. You can also double-click the CK_BirthDate constraint.
Another instance of the Transact-SQL editor appears and shows the definition for the CK_BirthDate constraint on the dbo.Employees table.
In the final step, you put your solution, which contains the database project, under version control.
To put your solution under version control
On the File menu, point to Source Control, and click Add Solution to Source Control.
Click the version control project (Team Foundation Server refers to these as Team Projects) to which you want to add the solution by using procedures for your source control add-in. For more information, see Working with Team Foundation Version Control.
Your database project is now under version control. If you do not need to make additional changes, you should check in the files in your solution.