Writing and Changing Database Code

After you put your database or server under version control and define a testing baseline for your project, you and your team spend most of the development cycle performing various iterative development tasks. Each of these tasks includes a few simple steps:

  • Understand the task.

  • Synchronize your development environment.

  • Check out files, and make the necessary changes to the database project or the server project.

  • Refactor the code and data.

  • Build and deploy the project into your isolated development environment.

  • Test your changes, which might include generating test data.

  • Analyze the new or modified code to identify potential problems.

  • Check in your changes to share them with the team.

  • Troubleshoot any issues.

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.

Task

Supporting Content

Identify and understand the task: In a team environment, your work often corresponds to a work item in Visual Studio Team Foundation Server. After you find and understand the work item, you might need to learn about the code that you will be changing.

Synchronize your development environment: Before you begin a task, you might need to get the current version of the project from version control. If changes were made to the production or staging server that are not reflected in the project, you might need to update the project before you begin your development task.

Modify the objects, settings, or scripts for the project: To complete the development task, you typically must modify objects, settings, or scripts in the database or server project.

Refactor the code and data in the database or on the server: You can use database refactoring to eliminate some repetitive and error-prone tasks, such as renaming all references to an object, fully qualifying names, expanding wildcard characters, or moving an object to a different schema.

Build and deploy changes to your isolated development environment: After you modify the project, you build and deploy the changes to your isolated development environment. You can test your changes in isolation before you share them with other team members.

Test your changes: 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 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 environment with data from a test, staging, or production server.

Identify potential issues by analyzing your code: You can analyze your database code to find and fix common design, naming, and performance issues. For example, you can find database code that might cause a table scan when you run it.

Check in your changes: After you test your changes and analyze the code for potential problems, you can check your changes in to version control so that you can share them with your team. When you check in your changes, you must also resolve any related work items.

Troubleshoot common project, build, or deployment issues: You can learn how to resolve common problems that you might encounter when you work with database and server projects, such as when you build or deploy them.

See Also

Concepts

Managing Database Change