TFS database backup job failed with error: TF30040

Full Error

TFS database backup job failed with error: TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator.System.Data.SqlClient.SqlException (0×80131904): Could not find stored procedure ‘prc_TfsSetTransactionLogMark’.


We started getting an error in the event log everytime our backups ran that had the below details in it.

Exception Message: TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator. (type DatabaseConfigurationException)
Exception Stack Trace:    at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.TranslateException(Int32 errorNumber, SqlException sqlException, SqlError sqlError)
   at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.TranslateException(SqlException sqlException)
   at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.MapException(SqlException ex, QueryExecutionState queryState)
   at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.HandleException(Exception exception)
   at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.Execute(ExecuteType executeType, CommandBehavior behavior)
   at Microsoft.TeamFoundation.Framework.Server.TeamFoundationSqlResourceComponent.ExecuteNonQuery(Boolean bindReturnValue)
   at Microsoft.TeamFoundation.Admin.AdminSqlResourceComponent.ExecuteNonQuery(SqlQuery sqlQuery, SqlInfoMessageEventHandler infoMessageHandler)
   at Microsoft.TeamFoundation.Admin.SqlHandler.ExecuteNonQuery(String connectionString, SqlQuery sqlQuery)
   at Microsoft.TeamFoundation.Admin.SqlHandler.ExecuteNonQuery(String connectionString, String sqlStatement)
   at Microsoft.TeamFoundation.Admin.Jobs.DatabaseBackupJob.TakeTransactionalBackups(TeamFoundationRequestContext requestContext, BackupSettings settings, ITFLogger logger)

Inner Exception Details:

Exception Message: Could not find stored procedure ‘prc_TfsSetTransactionLogMark’. (type SqlException)
SQL Exception Class: 16
SQL Exception Number: 2812
SQL Exception Procedure:
SQL Exception Line Number: 1
SQL Exception Server: <SERVER>
SQL Exception State: 62
SQL Error(s):

The problem started occurring after we started restoring backups from our production instance into our test/dev TFS environment.


After attaching/restoring a new collection you must reconfigure your TFS scheduled backups.

Reason for error

When you configure your scheduled backups the application creates the stored procedure ‘prc_TfsSetTransactionLogMark’ in all the databases that would be backed up. Because we detached our collection on one server and then reattached it on another (that was originally configured to backup) and didn’t reconfigure the backups, the scheduled would assume that the collection database has this procedure and tries to execute using it.


TFS Api – July 2013 Release

The July release is focused on the Test Management around importing test cases from other systems and contains a xml parser for Test Link to easily enable Teams using Test Link to move to TFS Testing Tools of TFS, below is a quick over of what you can find when trolling through the API and source code.

  • Test Management
    • Import from test link
  • Administration
    • Global List
      • Load Global List from Server
      • Save Changes to server (option to create if not exists)
  • Queries
    • Execute (passing in wiql)
    • Execute Saved Query (passing in path to query saved in TFS queries)

You can find the current documentation on the documentation site,

The code in the API is targeted at TFS 2012 and uses some Visual Studio 11 (2012) features to interact with TFS. Although some code might work against other version, it was not tested with those versions.

The Codeplex release can be found here.

Please feel free to provide feedback on the API. Any and all feedback will be read and discussed.


    TFS Auto Complete Fields

    In TFS you are able to customise your process template and one of the rules you can add to a field is a SuggestedValues rule, with this you can specify many single items for suggestions or/and get the suggestion items from a global list. This works great for if you have a set list of suggestions, but what if you want to pull your suggestion list based off data in TFS.


    Reading this we are assuming that you have a understanding of the basics of customising a process template.

    Create the Magic

    Add a field

    Add a new field to any work item called The Auto Completing Field. Make it’s reference name be Fields.The.Auto.Completing.Field. Leave the type as string and import the work item definition into TFS.

    Create a Team Query

    Browse to any of the interfaces where you can create a flat query. Start a new Query,


    And for this example create your query as below.


    For Column options select just the “The Auto Completing Field” field, and in the sort columns select the same column. Save that query in the root of Shared queries.

    Creating the server plugin

    The plugin you will create is very simple and you will be able to use the source attached directly. Basically what you are going to do is whenever the configured fields are changed then you will call the query mapped to that field and update a global list which you will add as a suggested list for your field after the global list is created.


    The code that does the logic magic is below and all the classes being called are in the source download

    Uri requestUri = GetTFSUri(requestContext);
    foreach (StringField field in workItemChangedEvent.ChangedFields.StringFields)
        if (DoesFieldNameExistsInConfiguredFields(configuredFreeTextFields, field.ReferenceName))
            IGlobalList globalList = GlobalListFactory.GetGlobalList(requestUri, _configuredFreeTextAutoCompleteGobalListPrefix + field.ReferenceName.Replace(".", "_"));
            IQueryRunner queryRunner = QueryRunnerFactory.CreateInstance(requestUri, workItemChangedEvent.PortfolioProject);
            WorkItemCollection workItemsFromQuery = queryRunner.ExecuteSavedQuery(configuredFreeTextFields[field.ReferenceName]);
            foreach (WorkItem wi in workItemsFromQuery)
                if (wi.Fields.Contains(workItemsFromQuery.DisplayFields[0].Name))

    The bits of code around the above code load configured fields from the app settings. A default example of what the config would look like for the field created in this article is below.


    Final Touches

    The server plugin should create the global list for you if it doesn’t exist, so if you go into TFS and alter the “The Auto Completing Field” then the global list for the field will be created, alternatively if you are using the default configuration you can import a global list upfront called AutoComplete_Fields_The_Auto_Completing_Field.

    Basically after the global list is in TFS (no matter which method you use to get it there), you need to go back to your work item definition and add the SuggestedValues rule that uses the global list created as it values.

    Publish the server plugin and import the changes made to the work item definition and we’re done =)


    This plugin allows you to give users the flexibility to use free text fields and by making a auto complete type experience helps a bit to not have multiple values for the same thing that will later make accurate reporting slightly tougher.




    TF400324: Team Foundation services are not available from server…

    Full Error

    TF400324: Team Foundation services are not available from server <Server/CollectionName>. Technical information (for administrator):   Page not found.


    This error could occur if you have moved a collection from one server to another and a client application connects to both servers. In my case this is because I’m running TFS 2012 on one server for production use and have backed up and restored a collection to a newly installed TFS 2013 Preview so that I can configure the process template (Upgrading to Visual Studio Scrum 3.0 process template in TFS 2013) to take advantage of the new features in 2013 and test that before moving/upgrading the production server.

    Quick Fix

    As a quick fix you can

    1. Close Visual Studio and related apps
    2. Browse to %LocalAppData%\Microsoft\Team Foundation\4.0\Cache and delete all the contents of that folder

    This isn’t ideal as you will need to do this for each client and every time you switch between the 2.

    Better Fix

    As a better and more user friendly fix, you can

    1. Do the Quick Fix
    2. TS to the server where you have The new TFS server with a copy of your collection attached (my TFS 2013 instance)
    3. Open a command line window in Administrator mode
    4. Run cd “C:\Program Files\Microsoft Team Foundation Server 12.0\Tools”
    5. Run tfsconfig ChangeServerID /sqlinstance:<Your Sql Instance Name> /databasename:<Your configuration Database Name> /ProjectCollectionsOnly
    6. This should bring up a message that says “The command ChangeServerId should only be run against a set of Team Foundation Server databases that have no application tiers configured. Do you want to continue with this operation? (Yes/No)
    7. Type Yes and hit enter

    Now you should be fine to use both instances of TFS with the same collection name without issues


    Changes to the Alert Settings in TFS 2013

    Small changes make a big difference. With TFS 2012 you had SMTP settings for alerts that contained the very essentials for sending out mail and look like this.image

    This works fine until, people for some reason don’t get emails, now you will probably end up moving work items around to force sending of alerts as a test mechanism. With 2013 the whole alerts settings window has changed a lot and caters for more inputs for configuration. And the best part of it (for me at least) is that there is now a Send Test Email window.


    Pretty neat and does exactly what it should Smile.


    TF237165: Team Foundation could not update the work item because…

    Full Error Message

    TF237165: Team Foundation could not update the work item because of a validation error on the server. This may happen because the work item type has been modified or destroyed, or you do not have permission to update the work item.


    A while back I received the TF237165 error message from TFS when reordering work items on the backlog. I did what most people would do and went to Google for while, none of the post I found seemed to help (I thought). After a while of trying to figure out what’s going on by trying all kinds of things from profiling SQL, enabling Trace on the web access site and trying to get some useful information using fiddler.


    Not really a good workaround but for the work items that were breaking I was able to open the items and manually change the backlog priority to a number in between the backlog priority of the 2 work items I wanted to move the broken work item between. This was fine for a while because it wasn’t happening that often. Recently though opening some work items and changing any information on them resulted in the same error message above and over the last 2 or so weeks started showing up more and more.


    I tried all the previous methods of finding the problem and came up dry again. I went back to Google. I ended up finding a couple of posts on pages (not marked as answer) saying that it could possible be the rules on the WIT definition that is causing this error.


    Note : It is advised not to experiment with finding the solution directly on a production system.

    To easily see if this was the issue for me I removed all FIELDS nodes from under the STATE nodes and from under the TRANSITION nodes. Importing the definition into TFS and “magically” all my problems went away. While not quite, all of the rules were required for some or other reason in the processes that were defined. I then reverted all my changes and now focused only on the rules themselves with the FIELDS, I removed a couple of fields that I thought could specifically be causing the issues and imported again, again the problem was fixed and now I had a smaller problem area.

    The fields that I removed were the Microsoft.VSTS.Common.ActivatedBy and Microsoft.VSTS.Common.ActivatedDate but only in the STATES node.


    Reverted changes again, Now having only these two fields to work with now I ended up next changing the SERVERDEFAULT rule to COPY and importing again. This still worked and I’m assuming is the solution for the issue.


    Using TFS Kanban Column State to the warehouse

    For a while I have been wondering and querying if it is possible to see or use the customizable Kanban columns in the warehouse for reporting purposes. The answer many times come up as no. Having done a lot of customisation of TFS lately I decided to take a stab at it.

    Below is my solution for getting the Kanban column state into the warehouse.


    First you’ll need to add a custom field to a Work Item Type, in a previous post Getting Html Fields Data into your TFS Warehouse I show how to add a new field. For this example we will add a new field that matches the images below.


    Note : There will be no reason to add this field to the layout.


    Next we will create a new Subscriber. Create a new Class Library and add a reference to

    Microsoft.TeamFoundation.Framework.Server.dll, v11.0.0.0 – This assembly can be found in the project files attached but also in the directory C:\Program Files\Microsoft Team Foundation Server 11.0\Tools on the TFS server.

    The function of interest for this post if the PopulateKanBanColumnField, this method is shown below but you can grab the project code and see the full implementation.
    Update – Works with TFS 2012

    private bool PopulateKanBanColumnField(WorkItem wiCurrent)
        bool result = false;
        if (wiCurrent.Fields.Contains("KanBan State") && wiCurrent.Fields["Work Item Type"].Value.ToString() == "User Story")
            foreach (Field field in wiCurrent.Fields)
                if (field.Name.ToLower().EndsWith(".kanban.column") && this.IsGUID(field.Name.Remove(field.Name.ToLower().IndexOf(".kanban.column"))) && wiCurrent.Fields["KanBan State"].Value != field.Value)
                    wiCurrent.Fields["KanBan State"].Value = field.Value;
                    result = true;
        return result;

    Update – Changes made in TFS 2013 with naming of field, it now in the format “WEF_(Guid)_KanBan.Column”


    Now compile this and copy the output assemblies to C:\Program Files\Microsoft Team Foundation Server 11.0\Application Tier\Web Services\bin\Plugins on the TFS server.


    1. Every time you move a work item that this subscriber effects it will save 2 revisions to the system, i.e.: when moving from Backlog to In progress it will save the work item and then the rule will fire find that work item in the store and then update the field.
    2. I have only tested that this works with TFS 2012 Update 2
    3. If a requirement is visible on 2 teams boards, then you need to read the extended column values for both teams and not stop after the first


    Hope this helps and allows for more people to use the Kanban columns in there teams because they can now report on it Smile.



    TFS Api – May 2013 Release

    Earlier this month it was announced that we are working on an API that wraps around the current TFS API. We have now released the first publicly available release of the API.

    Our first release is focused on the Administration of TFS, below is a quick over of what you can find when trolling through the API and source code.

    • Team Project Collections
      • Create
      • List
      • Delete**
    • Team Projects
      • Create
      • List
      • Delete*
    • Process Templates
      • List
      • Upload
      • Download
      • Set Default
      • Delete
    • Iterations
      • List
        • Flat
        • Tree
      • Add
      • Delete
      • Check if a path already exists
      • Check if the Iteration path is visible for iteration planning

    * Requires Visual Studio installation (uses command line).

    ** Needs to run on the TFS Server

    We will be adding more to the administration namespace as well as working on other areas of TFS. At a quick glance you can see that the Area management is currently missing, this will be including in future versions of the API and will have a similar structure to the iterations.

    You can find the current documentation on the documentation site,

    The code in the API is targeted at TFS 2012 and uses some Visual Studio 11 (2012) features to interact with TFS. Although some code might work against earlier version, it was not tested with those versions.

    The Codeplex release can be found here.

    Please feel free to provide feedback on the API. Any and all feedback will be read and discussed.


    Persisting Modern UI for WPF styles

    About 2 weeks ago I blogged about Creating a Modern UI for WPF, the template by default doesn’t persist styles selected in the settings menu through application launches. So I’m going to give you the steps required to make this feature happen to complete feel of the template Smile.

    First follow all the steps in the previous post, then you will need to add a new settings file to the project


    Next you will need to add 4 settings,


    Name : SelectedAccentColor, Type : System.Windows.Media.Color, Scope : User, Value : #FF1BA1E2


    Name : SelectedThemeSource, Type : System.Uri, Scope : User, Value : /FirstFloor.ModernUI;component/Assets/ModernUI.Dark.xaml


    Name : SelectedThemeDisplayName, Type : string, Scope : User, Value : dark


    Name : SelectedFontSize, Type : string, Scope : User, Value : large

    Next you will browse to Content\SettingsAppearanceViewModel.cs, Add a private member bool called _colorLoadedYet with a default value of false.

    private bool _colorLoadedYet;

    Now look for a method called SyncThemeAndColor and paste the code below at the bottom of that method

    if (this._colorLoadedYet)
        ApplicationSettings.Default.SelectedThemeDisplayName = this.SelectedTheme.DisplayName;
        ApplicationSettings.Default.SelectedThemeSource = this.SelectedTheme.Source;
        ApplicationSettings.Default.SelectedAccentColor = this.SelectedAccentColor;
        ApplicationSettings.Default.SelectedFontSize = this.SelectedFontSize;

    Also add a method called SetThemeAndColor as below

    public void SetThemeAndColor(string themeSourceDisplayName, Uri themeSourceUri, Color accentColor, string fontSize)
        this.SelectedTheme = new Link { DisplayName = themeSourceDisplayName, Source = themeSourceUri };
        this.SelectedAccentColor = accentColor;
        this.SelectedFontSize = fontSize;
        this._colorLoadedYet = true;

    For the font size setting we going to go to the SelectedFontSize property and code below after the line this.OnPropertyChanged(“SelectedFontSize”);

    if (_colorLoadedYet)
        ApplicationSettings.Default.SelectedFontSize = this.selectedFontSize;

    And for the final step, you must browse to the MainWindow.xaml.cs file and just after the InitializeComponent add the code below.

    SettingsAppearanceViewModel settings = new SettingsAppearanceViewModel();

    That’s all, you can now run your application and change the settings and they will persist through application launches. Through development this will reset often but won’t while your application is used by a user. For the best results replace the settings file with a more permanent storage location.



    The point of this Project is to get community members to develop a TFS API that does exactly what the API provided by Microsoft does just in a simple to use way.

    The API will expose bits and pieces of the underlining API with Basic implementations that use as many defaults as possible and more complex implementations that will let developers configure all the same options that they would be able to configure when using the raw API, they just won’t have to worry about learning the underlining API =).

    The aim/goal of this project is to get developers to add “user stories” or requests to the User Voice and then an active member of the project would give feedback on the request.

    We will aim to release an update to the API at least once a month.

    If you would like to contribute to this project please complete the contact page on the page, or request to join the project from the project site on Codeplex.

    The first release is currently scheduled for the end of May 2013 and will contain some basic API needs. More information around request and user stories will follow later in the month.

    Codeplex site :