How to link a SQL Server database to a source control system

Applies to

ApexSQL Source Control

Summary

This article explains how to link a database to the source control repository using the Source control setup window

Description

Using ApexSQL Source Control, a SQL Server Management Studio add-in, developers can link a database to the source control repository directly from SQL Server Management Studio.

Linking process

  1. Right-click on the database in the Object Explorer panel, and from the context menu, select the Link database to source control option:

    The Link database to source control command in the Object Explorer panel

  2. The Source control setup window will be displayed:

    The Source control setup window

    The Source control setup window consists of five steps (tabs), three mandatory and two optional:

    • Mandatory tabs:

      1. Connection type
      2. Development model
      3. System login
    • Optional tabs:

      1. Object filter
      2. Script options

Connection type tab

The Connection tab in the Source control setup window

Under the Connection type tab are present two options:

  • Native – requires a source control system to be specified from the Source control system drop-down list. On the Source control system list will be found all supported source control systems:
    • Git
    • Mercurial
    • Perforce
    • Subversion
    • Team Foundation Server (Azure DevOps Server/Services)

    Supported source control systems under the Connection tab in the Source control setup window

  • Working folder – allows linking a database to a file system folder without any source control system. This feature is convenient, e.g., evaluating purposes

    The Working folder option under the Connection tab of the Source control setup window

Development Model tab

Under the Development model tab, one of the two supported development models must be chosen to work with the source control systems:

  • Dedicated

    The Development model tab in the Source control setup window - the Dedicated option

  • Shared

    The Development model tab in the Source control setup window - the Shared option

Quick tip icon

Quick tip:

When you link a database on which multiple developers will work at the same time, the Shared database model is suggested

System login

Connecting to a source control repository requires appropriate login information to be provided as well as some additional information specific to the chosen source control system.

Here’s how login forms and the repository string specific to each source control system look like:

Git

The System login tab in the Source control setup for the Git source control system

The Repository path form:

<protocol>://<hostname>:<portnumber>/<Git server name>/<repository>

  • <protocol> – can be HTTP, HTTPS or SSH
  • <hostname> – the machine hostname, a NetBIOS name or a DNS  machine name that hosts the Git Server
  • <portnumber> – port 8443 is used by default
  • Using <Git server name> in the repository path is mandatory
  • <repository> – the name of the Git repository to connect to

Quick tip icon

Quick tip:

When connecting to a Git, Mercurial, or Subversion repository hosted in the local machine file system, the following form of the repository path is advised:

<LocalPathToRepository>\<repository>

Mercurial

The System login tab in the Source control setup for the Mercurial source control system

The Repository path form:

 <protocol>://<hostname>:<portnumber>/<repository>

  • <protocol>  can be HTTP, HTTPS or SSH
  • <hostname> – host machine, NetBIOS, or DNS name
  • <portnumber> – port 8443 is used by default
  • <repository> – the name of the Mercurial repository to connect to

Perforce

The System login tab in the Source control setup for the Perforce source control system

The Host path form:

<protocol>://<hostname>:<portnumber>

  • <protocol> – can be TCP which is the default, or SSL
  • <hostname> – the machine hostname, a NetBIOS name, or a DNS machine name that hosts the Perforce server
  • <portnumber> – port 1666 is used by default

Subversion

The System login tab in the Source control setup for the Subversion source control system

The Repository path form:

<protocol>://<hostname>:<portnumber>/svn/<repository>/

  • <protocol> – can be HTTP, HTTPS, SVN or SSH
  • <hostname> – host machine, NetBIOS, or DNS name
  • <portnumber> – port 8443 is used by default
  • <repository> – the name of the Subversion repository to connect to

Team Foundation Server (Azure DevOps Server/Services)

The System login tab in the Source control setup for the Azure DevOps Server/Services source control system

The Repository path form::

<protocol>://<hostname>:<portnamber>

  • <protocol> – can be HTTP or HTTPS
  • <hostname> – host machine, NetBIOS, or DNS name
  • <portnamber> – port 8080 is used by default

Quick tip icon

Quick tip:

When connecting to Azure DevOps Services, use the email address as a username and Token, created under user profile options, as a password

Object filter tab

This step provides a possibility to exclude objects from a database on which changes will not be tracked. It is possible to exclude specific objects, exclude objects by owner or type. More about this topic can be found in the Object filtering article.

The Object filter tab in the Source control setup window

Script options tab

This step of the Source control setup window is about setting the Ignore comparison and the Synchronization options for the selected database. More about options under this tab is explained in the Script comparison and synchronization options in ApexSQL Source Control article

The Script options tab in the Source control setup window

After the database is linked, the Action center tab will open with all checked objects under the Object filter tab listed:

The linked database and all objects present in the Action center tab, objects checked under the Object filter tab, will have a link icon (blue dot):

Icons for linked database and objects in the Object Explorer panel