How to: Control Data Loss during Deployment to Existing Databases

Data might be lost when you deploy changes in a database project to a database server if those changes cause database objects to be dropped and recreated. By default, such losses cannot occur because deployment is canceled if you try to deploy those types of changes. However, you can specify that deployment should continue even if data might be lost. You might take this approach if, for example, you can easily regenerate the data. This option might be appropriate if you are working in an isolated development environment on a database that you populated with test data by using Data Generator.

Note

You might have lost data if you renamed a table or a column in a version of Database Edition that is older than the general distribution release (GDR) of Visual Studio Team System 2008 Database Edition. This type of loss occurred because the operation would have been interpreted as a DROP and a CREATE when you deployed the project. In the GDR release, when you use database refactoring to rename a database object, the refactoring log file records the action and preserves your changes more precisely. When you deploy the project, the object is renamed in place, which prevents data loss in many cases. For more information about how to use refactoring to automatically update references after you rename an object, see Rename All References to a Database Object.

To allow data loss during deployment to an existing database

  1. Perform one of the following steps:

    • In Solution Explorer, expand your database project, expand the Properties node, and click the .deploymentconfig file that you want to modify. On the View menu, click Open.

    • Open the properties for your database project, and click the Deploy tab. In Deployment configuration file, click the file that you want to modify, and then click Edit. For more information, see How to: Configure Deployment Settings for Database and Server Projects.

  2. Clear the Block incremental deployment if data loss might occur check box.

  3. On the File menu, click Save Filename**.deploymentconfig**, where Filename is the name of the file that you modified.

    The changes to your project properties are saved. You can now deploy changes that could cause data loss.

To prevent data loss during deployment to an existing database

  1. Perform one of the following steps:

    • In Solution Explorer, expand your database project, expand the Properties node, and click the .deploymentconfig file that you want to modify. On the View menu, click Open.

    • Open the properties for your database project, and click the Deploy tab. In Deployment configuration file, click the file that you want to modify, and then click Edit. For more information, see How to: Configure Deployment Settings for Database and Server Projects.

  2. Select the Block incremental deployment if data loss might occur check box.

  3. On the File menu, click Save Filename**.deploymentconfig**, where Filename is the name of the file that you modified.

    The changes to your project properties are saved. You can no longer deploy certain types of changes that could cause data loss.

See Also

Tasks

Walkthrough: Deploy Changes to an Existing Version-Controlled Database

How to: Configure Properties for Deployment Details

How to: Configure Deployment Settings for Database and Server Projects

Concepts

An Overview of Database Build and Deployment

An Overview of Database Project Settings

Terminology Overview of Database Edition