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 ApexSQL Source Control wizard

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

To link a database:

  1. Select the database to be linked to a source control in the Object Explorer pane
  2. Right-click on the database, and form the context menu, select the Link database to source control option from the ApexSQL Source Control submenu:

    Selecting Link database to source control from the ApexSQL Source Control submenu

  3. The Source control setup wizard will be displayed:

The Source control setup wizard consists of three steps:

  1. System selection
  2. Object filtering
  3. System login

 
System selection

ApexSQL Source Control allows using any of the supported source control systems:

Working folder feature can also be used to link database to any folder in the file system. This feature is convenient for e.g. evaluating purposes or linking the database to local repository folder created by third party source control client.

One of the two standard development models must be specified for working with the source control systems:

Quick tip icon

Quick tip:

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

Object filtering

This step provides possibility to exclude objects not to be linked to source control. It is possible to exclude specific object, exclude objects by owner or type. Learn more

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 Repository path form:

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

  • <protocol> – can be http, https or SSH
  • <hostname> – the machine host name, 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:
file:\\<LocalPathToRepository>\<repository>

 
Mercurial

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 Repository path form:

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

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

Subversion

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 / Visual Studio Online

The meaning of the fields:

  • TFS server– the path to the selected source control repository. It requires to be entered in the following form:
    <protocol>://<hostname>:<portname>/tfs
    • <protocol> – can be http or https
    • <hostname> – host machine, NetBIOS, or DNS name
    • <portname> – port 8080 is used by default
    • Using /tfs in the repository path is mandatory
  • Folder location – the folder in the Team Foundation Server that stores the source control files
Quick tip icon

Quick tip:

When connecting to Visual Studio Online, use the alternate authentication credentials password created under user profile options.
The correct repository patch is:
https://<acountname>.visualstudio.com/DefaultCollection

After the database is linked, you can initially commit all objects to the repository from Action center. The database object status will be refreshed and shown as linked via the appropriate icon:

The database object status is refreshed and shown as mapped

FAQs

Q: What if I’m using other team project collection on VSO (not the Default Collection), should I include it in the repository path?

A: Yes, you should use it instead of the Default Collection, so the repository path will be:
https://<acountname>.visualstudio.com/<custom collection>

Q: Can I use a third party source control client like TortoiseSVN together with ApexSQL Source Control?

A: Yes. It can be done by using the Working Folder feature which enables the user to script database changes using ApexSQL Source Control and to use any third party client to commit changes to the repository.

Q: Do you plan to include support for any other source control systems?

A: Yes. From ApexSQL Source Control 2016 R1 user will have the ability to use any source control system that supports the Command Line Interface.