Introduction to dbForge Source Control

When developers work with databases across different environments, version control helps keep database development consistent. dbForge Source Control is an add-in for SQL Server Management Studio (SSMS) that links SQL Server databases to shared repositories, enabling you to version-control database schemas and static data. It supports TFS, Apache Subversion (SVN), TFVC, Git (including Azure DevOps, GitHub, GitLab, and Bitbucket), Mercurial (Hg), Perforce (P4), and SourceGear Vault.

You can use dbForge Source Control to:

  • Commit local changes and pull remote changes.
  • View the history of changes for a database or a specific database object to understand what changes were made, who made them, when they were made, and why.
  • Revert uncommitted changes.
  • Resolve conflicts.
  • Switch between branches or merge them.
  • Update a database to a specific revision.

dbForge Source Control workflow

Team models

dbForge Source Control supports two team models that can work with multi-instance development:

  • Dedicated – Developers work with their own copies of the database.
  • Shared – All developers work on a single shared database.

Dedicated vs shared development models

dbForge Source Control operations

dbForge Source Control enables you to set up a standard version control workflow directly in SQL Server Management Studio and perform all the required version control operations.

Commit changes to a repository

After you make changes, dbForge Source Control compares your current database copy with the version in source control and detects any differences. You can then either commit the changes or discard them.

To commit your changes, select them in the Local changes section, enter a commit message, and click Commit. This updates the source control repository with your local changes.

To discard uncommitted changes, click Undo.

Commit changes to a repository

Get remote changes from version control and deploy them to the database

You can update your local database copy to synchronize it with changes made by other developers. All changes appear in Source Control Manager. Refresh it to check for the latest updates.

To update your local database copy, select the changes in the Remote changes section and click Get Latest.

Get the latest version

View the history of changes

You can view the change history to see who committed each change, when it was committed, and why. You can also compare versions to review the differences between them.

Change history

Resolve conflicts

Conflicts can occur when multiple developers make different changes to the same database objects or data simultaneously.

To prevent conflicts, consider the following:

  • Pull changes from the repository regularly.
  • Assign object ownership to specific developers.
  • Use clear commit messages and communicate changes with your team.
  • Commit changes frequently, keeping each commit focused.

Conflicts

If a conflict occurs, the resolution strategy is:

  • Get Remote – Accepts the repository version and discards your local changes.
  • Get Local – Keeps your local changes and overwrites the repository version.

Alternatively, resolve the conflict manually by editing the SQL script to combine both sets of changes.

After resolving the conflict, test the merged version to ensure it works as expected.

Manage static data

dbForge Source Control supports versioning of static data. You can link static data, modify it, commit changes, and resolve conflicts.

When synchronizing static data with the production environment, consider the following:

  • Use separate commits for schema and data changes.
  • Review data changes before deploying them to production.
  • Prepare a rollback strategy for data changes.

Commit static data

Recommended workflow with dbForge Source Control in a multi-instance environment

1. Set up your repository.

2. Link a development instance to your repository.

3. Link additional database instances.

4. Set up the change management process.

5. Automate the deployment process:

  • Use dbForge Schema Compare for validation.
  • Implement CI/CD pipelines.
  • Automate testing in a staging environment.
  • Create a deployment script.

Video tutorial

Watch this video to learn how dbForge Source Control works and what version control operations you can perform.