How to Set Up Source Control: a Short Guide for Evaluators

July 30th, 2019

dbForge Source Control is a powerful SSMS add-in for managing SQL Server database changes in version control systems. The tool allows version-controlling schemas and reference data, rolling back changes, and maintaining the referential integrity of your SQL databases.

This solution can also solve other database challenges, including deployment without losing data. dbForge Source Control can link your databases to all common source control systems, including SVN, TFVC, Git, Perforce, Mercurial, and SourceGear Vault. By any definition, dbForge Source Control delivers a smooth and clear workflow in a familiar interface.

This guide is aimed at providing information about setting up and using the dbForge Source Control tool with your database and version control system, as well as getting started, committing and getting changes, and sharing options with the team. If you already own dbForge Source Control and need help getting set up, visit our documentation center to learn how to get started and how to use dbForge Source Control.

Linking a database to source control

In dbForge Source Control, you can connect a SQL database to:

  • Team Foundation Version Control (TFVC)
  • Subversion (SVN)
  • SourceGear Vault
  • Git (including GitHub, GitLab, and Bitbucket)
  • Perforce (P4)
  • Mercurial
  • Working folder
  • Command-Line Interaction

For more information about how to link a SQL database to the supported source control systems, see our documentation center.

In our example, we are going to link the database to Git. To begin with, make sure that you have created the Git repository locally on your computer or cloned it from the remote repository.

In Object Explorer, right-click the database you want to link to source control and then select Source ControlLink Database to Source Control.

Link a database to source control in dbForge Source Control

In the Link Database to Source Control wizard that opens, under Source control repository, click + to select a source control repository.

Link a database to a source control repository in dbForge Source Control

Next, in the Source Control Repository Properties dialog box that opens, do the following:

  • Select Git in the Source control system drop-down list.
  • Specify the directory to the local copy of the remote repository in the Repository folder box and click OK to close the Source Control Repository Properties dialog box.
  • (Optional) Click Test to verify that the connection was successfully established and then click OK.
Specify source control settings in Source Control Repository Properties dialog box

Then, in the Link Database to Source Control wizard, select a database development model and click Link. For more information about database development models, see Shared vs Dedicated Development Models: Key Differences. And finally, click Link. If a database is linked to source control successfully, a database icon in Object Explorer will be changed to show that a database is linked.

View a successfully linked database in Object Explorer

Making an initial commit

After you have linked the database to source control, you can make the first commit. This will get a copy of your database into source control.

To make a commit, right-click a linked database in Object Explorer and then select Source ControlCommit.

Make the first commit to the source control repository in dbForge Source Control

In the Source Control Manager that opens > Local changes section, do the following:

1. Select objects you want to commit.

2. Write a comment in the text box and click Commit.

If you do want to discard the changes that have not been committed to source control yet, click Undo.

Select the database objects you want to commit in the Local changes section and make the first commit

The Commit dialog box showing all the stages of the commit operation opens. During the process, the tool will ask you to log in to your GitHub account. Once done, click OK to close the dialog box to complete the operation.

The stages of the commit operations

The Refresh window appears after that.

The stages of the Refresh operation

After closing the Commit and Refresh windows the changes are added to the repository.

Getting changes

To update your local version with the latest changes from source control, in Object Explorer, right-click a linked database you want to update and then select Source Control > Get Latest.

Update the local copy with the latest changes retrieved from the remote repository

In the Source Control Manager that opens > Remote changes section, select the database objects you want to update and click Get Latest.

Update the local version with the latest changes from the remote repository

The Get Latest dialog box showing all the stages of the get latest operation opens. When all stages are complete, click OK to close the dialog box to complete the operation.

Synchronize the changes and complete the operation

After closing the Refresh window your repository will be updated.

Linking static data with dbForge Source Control

You can configure dbForge Source Control to suit your development process. When you make any changes, they appear in the Commit changes pane at the bottom of the Source Control Manager. After you commit, other members of your team can get your changes by performing the Get Latest operation. This makes sure that everyone works with the same versions.

To link data change tracking (static data) to the repository, in Object Explorer, right-click the linked to source control database containing tables with static data and select Source Control > Link/Unlink Static Data.

Link static data to the repository in dbForge Source Control

In the Source Control Link Static Data window that opens, select the tables with static data you want to link and click Apply.

Keep in mind that static data can be linked to tables with primary keys.

Static data can be linked to tables with primary keys

Once done, the Source Control Manager opens displaying static data objects in the Local changes section.

View static data objects in the Local changes section of Source Control Manager

Now, select the objects and click Commit to push data to the repository.

Sharing static data changes with your team

If it is necessary for all your team to work with the same versions, they can get the changes you’ve made by clicking Get Latest in the Remote changes section.

Update the local copy with the latest changes retrieved from the remote repository

Conclusion

dbForge Source Control comprises an advanced tool that links a database to the source control system, so that developers can share changes to reference data and schemas, check the history of database changes, and roll back anything they need, without leaving SQL Server Management Studio. dbForge Source Control unfailingly helps maintain the referential integrity of the database. If you want to try our solution you can download it from our site.

Overview the main features and capabilities available in the SQL Tools pack

Comments are closed.


Your subscription could not be saved. Please try again.
Confirm your email by clicking the link in your inbox!

Subscribe to our blog

to get the latest posts delivered to your inbox