Export (0) Print
Expand All

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.

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 MyAdvWorks solution

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

    The Open Project dialog box appears.

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

    The MyAdvWorks solution opens and appears in Solution Explorer. Next, you specify your build configuration settings.

To configure your build and deployment settings

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

  2. On the Project menu, click MyAdvWorks Properties.

    The project properties window appears.

  3. Click the Deploy tab.

    NoteNote

    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 AdventureWorks2008 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 (MyAdvWorks.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 MyAdvWorks (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 MyAdvWorks.

    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\MyAdvWorks\MyAdvWorks\Debug\sql". The file name consists of MyAdvWorks.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 MyAdvWorks (the project, not the solution).

  2. On the Build menu, click Deploy MyAdvWorks.

    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.

If you want to verify that your changes were deployed, you can browse the updated database by using the Transact-SQL editor or Server Explorer in Visual Studio. For more information, see Editing Database Scripts and Objects with the Transact-SQL Editor on the Microsoft web site and Server Explorer/Database Explorer. You could also compare your database project to the deployed database by using the Schema Compare feature of Visual Studio Premium and Visual Studio Ultimate.

Community Additions

ADD
Show:
© 2015 Microsoft