Walkthrough: Deploy Changes to an Existing Version-Controlled Database

In this walkthrough, you deploy changes from your database project to an existing database server. This task includes configuring your build and deployment settings for updating your database, building the database project, and deploying the changes.

Prerequisites

This walkthrough assumes that you have completed both Walkthrough: Put an Existing Database Schema Under Version Control and Walkthrough: Modify Database Objects. If you have not completed both walkthroughs, you will not have a database project with pending changes to deploy to a target database.

To open the MyNorthwind solution

  1. On the File menu, point to Open, and click Project/Solution.

    The Open Project dialog box appears.

  2. Browse to the MyNorthwind folder, and double-click MyNorthwind.sln.

    The MyNorthwind solution opens and appears in Solution Explorer.

  3. Expand the Schema Objects subfolder if it is not already expanded.

    Next, you specify your build configuration settings.

To configure your build and deployment settings

  1. In Solution Explorer, click MyNorthwind (the project, not the solution).

  2. On the Project menu, click MyNorthwind Properties.

    The project properties window appears.

  3. Click the Deploy tab.

    Note

    If you had multiple configurations, in the Configuration list, you would click the configuration that you wanted to modify.

  4. In the Deploy action list, click Create a deployment script (.sql) and deploy to the database.

  5. Click the Edit button next to Target connection.

  6. Specify the connection information for the Northwind sample database from which you imported the schema in Walkthrough: Put an Existing Database Schema Under Version Control.

  7. Click the Edit button next to Deployment configuration file.

  8. Select the Block incremental deployments if data loss might occur check box if it is not already selected.

  9. Accept the default values for the other options. On the File menu, click Save All.

    Your changes to the project settings are saved to the database project file (MyNorthwind.dbproj) and to the Properties\Database.sqldeployment file. When you save the changes, the files are checked out of version control.

    Next, you build the update script for your database project.

To build your database project

  1. In Solution Explorer, click MyNorthwind (the project, not the solution).

    Note that, on the Standard toolbar, Debug is selected in the Solution Configurations list.

  2. On the Build menu, click Build MyNorthwind.

    Your database project is built. When the build completes, the Output window displays Build Succeeded. The compiled database schema is created in "My Documents\Visual Studio 2008\Projects\MyNorthwind\MyNorthwind\Debug\sql". The file name consists of MyNorthwind.dbschema. This file is an XML representation of the database project schema.

    In the final step, you will deploy your changes to the target database.

To deploy your build script

  1. In Solution Explorer, click MyNorthwind (the project, not the solution).

  2. On the Build menu, click Deploy MyNorthwind.

    Your database project is deployed. When the deployment completes, the Output window displays Deployment Succeeded.

    The changes that you made in the prior walkthrough have been deployed to the database server. You and your team could continue to make changes to the database project, deploying those changes when they were ready to be put on the server.

Next Steps

If you want to verify that your changes were deployed, you can browse the updated database by using the Transact-SQL (T-SQL) editor or Server Explorer in Visual Studio. You could also compare your database project to the deployed database by using the Schema Compare feature of Visual Studio Team System Database Edition.

See Also

Tasks

Walkthrough: Create and Deploy a New Version-Controlled Database

Walkthrough: Put an Existing Database Schema Under Version Control

Walkthrough: Modify Database Objects

Concepts

Build and Deploy Databases to an Isolated Development Environment

Compare and Synchronize Database Schemas

Terminology Overview of Database Edition