Microsoft's new cloud version of Team Foundation Service was released a couple of months ago on tfs.visualstudio.com, and given that we use Red Gate's excellent SQL Source controlproduct to manage database changes here at Red Jungle I expect more and more people will be like us and want to link their databases to their TFS server they have set up on tfs.visualstudio.com. I have just done this, and, (mostly because of the inaccurate instructions that Red Gate has published at the moment), you currently have to jump through a few hoops to get this all working nicely. I thought I would share my experience, hopefully saving some people a bit of time. (Note: I am assuming below you use Visual Studio 2012).
First of all, make sure you have at least version 3.1 of SQL Source Control installed. If not update.
Then, when you try to link a database to SQL Source Control, there is a little notice sitting under the server URL box:
This link, however, takes you to a page which has totally incorrect instructions. So please ignore this one. Google a bit and you probably get to
http://sqlblog.com/blogs/andy_leonard/archive/2012/10/08/redgate-sql-source-control-and-tfspreview.aspx, which is a better, but still has a vital error in it with regards to the configuration file content.
The following steps got me to over the line:
- Close SQL Server Management Studio
- Install Microsoft Team Explorer Client, you can download it from here: http://www.microsoft.com/en-us/download/details.aspx?id=30656
- Manually edit the SQL Source Control configuration file
- Start SQL Server Management Studio again
- Select the URL for your server
- Browse for the folders where you want your database version information stored.
In these steps 3 and 5 are the ones that are essential and incorrect or missing on the links above. I will go into these a bit more.
Edit SQL Source Control Configuration file
The SQL Source Control file is located in the “Local” folder for your AppData. For me that is in:
C:\Users\Gerard\AppData\Local\Red Gate\SQL Source Control 3
Note that you may not see this folder, if you are not showing “hidden” folders in Windows Explorer. The file you need to edit is RedGate_SQLSourceControl_Engine_EngineOptions.xml.
Open this file in a normal text editor and edit it. Unless you have changed this already, you will see a self closing EngineOptions tag:
<EngineOptions version="3" type="EngineOptions" />
Because you need to end content in here, you will need to change this into a tag and a closing tag:
<EngineOptions version="3" type="EngineOptions">
Then insert the following tag inside the EngineOptions tag:
So far this is as in Andy’s blog, but this is not really correct yet. The next step is vital to make this work: Remove all the white space from this latest insert, including the line breaks! If you do not do this, you will just get an error message that you need to install Microsoft Team Explorer Client to be able to use SQL Source Control.
The content of your configuration file should then look like this:
Okay. So far so good. Start SSMS again and select the database to link. All you need to do now is connecting to your TFS server
Connecting to your TFS Server
To do this you need to specify the Server URL. For me the natural choice for this was to specify the visualstudio.com URL:
This however generates an error:
The solution is to add your TFS collection folder to the Server URL; we are just using the DefaultCollection at the moment:
And with that, I could browse to a folder for my Database and Migrations Scripts folder. Which made me a happy developer.