Export (0) Print
Expand All

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.

NoteNote

In the Visual Studio Premium or Visual Studio Ultimate, 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 .sqldeployment 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.sqldeployment, 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 .sqldeployment 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.sqldeployment, 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.

Community Additions

ADD
Show:
© 2014 Microsoft