Share via


Add Reference Data to Tables When You Deploy the Database

You can insert reference data into one or more tables in your database by adding statements to the post-deployment script of your database project. Before you insert data into a table, you can test whether it already contains data. If the table is not empty, you must clear the existing data or specify that you want to always re-create the database before you deploy it.

Common Tasks

In the following table, you can find descriptions of common tasks that support this scenario and links to more information about how you can successfully complete those tasks.

Common Tasks

Supporting Content

Create or update a post-deployment script: You can modify the post-deployment script for your database project to insert data into one or more tables. Instead of modifying the post-deployment script to add data, you can create a separate script and then include it as part of the post-deployment script.

How to: Specify Pre-Deployment or Post-Deployment Scripts

Build and deploy the database project: You should build and deploy your database project into your isolated development environment so that you can test your changes.

Build and Deploy Databases to an Isolated Development Environment

Test your changes before you check in: You can run existing unit tests against the modified database or server to verify that your changes do not break any behavior of your application. You can also create unit tests to verify a new or changed behavior. You might need to change your data generation plan to support new or changed unit tests. You might also want to update your isolated development database with data from a test, staging, or production server.

Run Database Unit Tests

Create and Define Database Unit Tests

Generate Test Data for Databases by Using Data Generators

Compare and Synchronize Data in One or More Tables with Data in a Reference Database

Check in your changes: After you have tested your changes to the post-deployment scripts, you can check your changes in to version control to share them with your team. When you check in your changes, you should also resolve any related work items.

How to: Add a Project or Solution to Version Control

Using the Check In and Pending Changes Windows

How to: Check In Pending Changes

How to: Resolve Work Items

Troubleshoot problems: You can learn more about how to troubleshoot common problems with database unit testing, database projects, build creation, and deployment.

Troubleshooting Database Unit Testing Issues

Troubleshooting Database Project, Build, and Deployment Issues

See Also

Concepts

Terminology Overview of Database Edition