Redgate SQL Source Control Now Supports Team Foundation Server 2015

In this brief feature review, we will take a look at the main features of Team Foundation Server 2015. More specifically, we will review features that a Redgate SQL Source Control user would likely encounter. A few of the features will be useful, but maybe less known; such as the cloak feature and why you may want to use it with a Redgate SQL Source Control linked database. This blog article is written as a member of the Friends of Redgate community.

If you are new to my blog, please follow me by providing your name and email postalBoxin the Postal Box located in the top right corner of this blog page. For more information about me, click my social media icons located just above my postal box. I can be found at Twitter, LinkedIn, Facebook, YouTube, and Google+.

For details about my company services and speaking events visit us at:
AIM Report Writing Events

The two (2) products that we will be discussing today are Redgate’s SQL Source Control and Microsoft’s Team Foundation Server 2015. Product information can be found at the following links:

SQL Source Control 5
Product Page
Documentation
Forums

Team Foundation Server
Product Page

The following article will be divided into three main topics.

These 3 topics are as follows:

A. How to Setup SQL Source Control to use Team Foundation Server

B. SQL Source Control Overview

C. Team Foundation Server Features

A) How to Setup SQL Source Control to use Team Foundation Server
sqlSourceControlTo get started using SQL Source Control, download and install the program executable (.exe) from the link provided above. Once the program has been installed, start the program by clicking the icon displayed to the right of this paragraph.

Once you have started the program, you will be prompted to connect to a SQL Server. Once you have connected to a SQL Server, you will need to link SQL Source connectSQLServerControl with a Database on the SQL Server that you just connected to.

After connecting to the SQL Server, select a database from the object browser on the left side of the window.

Once you select a database from object explorer, the window below will replace the window above. In the window below, choose ‘Link to my source control system’ and click NextselectDatabase

On the ‘Choose your source control system’ screen shown below, choose Team Foundation Server as the Source Control System and Click Next.linkSource
Note: Besides TFS, SQL Source Control is also compatible with Git, Subversion, and Vault.

chooseSourceControlSystem

Choose TFS as the Source Control System. Enter the TFS URL and define the database and migration scripts folders. Select your deployment model and Click Link.

 

 

 

Once a Link is complete, a Source Control Details Page is displayed. SQL Source Control is now setup to use Team Foundation Server.

chooseDatabase

 

 

 

 

 

 

sourceControlDetails

 

If you open Team Explorer in Visual Studio, or View TFS from the web, you can find the folder that was created for the database you selected.

 

 

 

B) SQL Source Control Overview

Most of the time, developers will use SQL Server Management Studio (SSMS) to access and use SQL Source Control. As you will see below, developers can get latest changes and commit changes without opening Team Explorer in Visual Studio. However, before we take a look at the basic commands available from SSMS, we will quickly review how Redgate organizes a SQL Server Database in Team Foundation Server (Visual Studio, Team Explorer shown below)

tfsFolderVS As you can see to the left, SQL Source Control creates a folder in the location and with the name you provided during setup. Under that folder, it has also created folders that represent the differ types of objects found in SQL Server. Some of these folders named after objects include: assemblies, data, database triggers, defaults, extended properties, functions, rules, security, sequences, service broker, storage, synonyms, tables, types, and views. SQL Source Control will also create another folder at the location and with the name that you provided at setup for your migration scripts.

 

 

Get Latest Changes and Commit Latest Changes
getCommitLatestChangesSince we chose a shared deployment, once we have linked a database, we need to get the latest changes from the source control library. This will make sure that you have the latest versions of SQL code and objects on your local file location. This location will map accordingly to where you had the setup create the database and migration folders in your TFS collection.

Once you have made your changes to SQL code, or objects, you can commit the latest changes to SQL Source Control. This will create a new version in TFS and remove any locks on other developers.

 

 

 

Other SQL Source Control tasks
otherSCTasksAlso from SSMS, you can select Other SQL Source Control tasks to choose from these following tasks: Undo Changes, Link, or Unlink Static Data, Edit Filter Rules, Add Migration Script for Specific Changes, and Unlink Data Base from Source Control.

While working in SSMS is a developer’s main interaction with SQL Source Control, there are many features of TFS that are not available from SSMS that a developer using SQL Source Control may need to know about.

 

 

 

 

C) Team Foundation Server Features
Along with these well-known source control commands (Get Latest, Committing Changes, Migrations, Object Locking), using TFS provides Redgate Source control with these important features:

Add Items to Folder
addItemsToFolderSince SQL Source Control Links to a database, and objects can be created and stored in source control, developer’s may not need this feature often. However, if you have some objects that you want to add using TFS, this is the command that you want to select.

 

 

 

 

 

 

Annotate
Use Annotate to see who did what and when. The number is the change set number associated with the annotation. Clicking this number will open the change set in Team Explorer (not shown here).annotate

 

 

Branching and Merging
branchingMergingBranching and Merging deals with how to branch the code development into multiple swim lanes such as devTeam1, devTeam2, and devTeam3. All of these branches will belong to a main branch that belongs to a test branch, that belongs to a production branch. There are many ways to design your branches. Some may not want a test branch, but do want a UAT branch, or others may want a hot fix branch.
Merging is the process of bringing multiple branches back into the main branch, or into other branches.

 

Check Out for Edit
checkoutForEditUse Check Out for Edit to check out Code, or Objects from Team Foundation Server. This will put a lock on the object to prevent other developers from making changes allowing for simple merging of code.

 

Cloak
cloakCloak is very useful in that it will allow folders to not be copied to your local Folder location. This may be useful if you have developers that are not SQL Server users sharing the same TFS Collection. You can cloak their folders and they can cloak yours.

 

 

 

Find
findFind allows you to search for objects by name, or change set number, status, or wild card.

It is also worth mentioning that you can search by change set as mentioned above and shown below and to the left, but you can also Roll Back. We can rollback by Items, Change Set, Ranges of Change Sets, and to Specific Versions.

 

 

Get by Change Set

getByChangeset

 

 

 

 

 

 

 

Rollback

rollback

 

 

 

 

 

 

Get Latest Version
getLatestVersionGet Latest Version is like Get Latest Changes above where is will get the latest code, or objects for your local file location.

 

 

 

 

 

 

 

 

Undo Pending Changes
undoPendingChangesUndo Pending Changes open a window will all of your changes displayed allowing you to select what changes to undo.

 

 

 

 

 

 

 

View History
View History will show a developer the history of code and objects in TFS. The numbers are change sets and like in the annotations above, clicking on them will open the change set in Team Explorer. The history also shows the User Name, Date and any Comments entered when the developer checked in the code, or objects.

viewHistory

In Conclusion, Redgate’s SQL Source Control is a slick and easy way to manage SQL Server Source Code, especially when using Team Foundation Server. In the end, developers will use a blend of commands provided by both SQL Source Control and Team Foundation Server. For this reason, we have discussed both tools in this article. We have also demonstrated how to configure SQL Source Control to work with Team Foundation Server.

We hope this article has been useful and we welcome your feedback and comments by replying to this post, or by asking a question on the social media sites mentioned above.