Issue [ TFS 2012.2 ] Detaching collection fails on SnapshotIdentities with object reference not set to an instance of an object



When you try to detach a Team Project Collection in Team Foundation Server the process fails on SnapshotIdentities with an “object reference not set to an instance of an object” error. While this does not inhibit the execution of TFS there is likely a good reason that you wanted to detach and found this issue.

Figure: object reference not set to an instance of an object

In this case I was trying to move the Collection to another server and this is a blocking issue.

Applies To

  • Team Foundation Server 2012
  • Team Foundation Server 2012.1
  • Team Foundation Server 2012.2
  • Team Foundation Server 2012.3
  • Team Foundation Server 2013 Preview


When you get these sorts of errors make sure that you look in the Event Log of the server and at the logs generated by TFS. In the event of an error there will be a link on the page that will open the relevant log in the Team Foundation Server Administration Console.

[11:16:24.010] ++ Executing - Operation: Snapshot, Group: Snapshot.TfsIdentities
[11:16:25.010] Executing step: Copy identities to collection database
[11:16:25.010]   Executing step: 'Copy identities to collection database' Identity.SnapshotIdentities (16 of 28)
[11:18:15.873]   [Error] Object reference not set to an instance of an object.
[11:18:15.877]   System.NullReferenceException: Object reference not set to an instance of an object.
[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.IdentityTransferHandler.Transfer()
[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.IdentityTransferHandler.Execute()
[11:18:15.877]      at Microsoft.VisualStudio.Services.Framework.IdentityStepPerformer.SnapshotIdentities(TeamFoundationRequestContext requestContext, ServicingContext servicingContext)
[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.TeamFoundationStepPerformerBase.Microsoft.TeamFoundation.Framework.Server.IStepPerformer.PerformStep(String servicingOperation, String stepType, String stepData, ServicingContext servicingContext)
[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.ServicingStepDriver.PerformServicingStep(ServicingStep step, ServicingContext servicingContext, ServicingStepGroup group, ServicingOperation servicingOperation, Int32 stepNumber, Int32 totalSteps)
[11:18:15.877] Step failed: Copy identities to collection database. Execution time: 110 seconds.
[11:18:15.883]   Clearing dictionary, removing all items.

In the log you can clearly see that the step that is failing is the “Snapshot.TfsIdentities”. What I believe that this does is create a package inside of the Collection database for the new TFS Instance that you are moving it to. This package needs to contain all of the Identities that have interacted with this TFS Instance. The likely cause of this error is that there are orphaned group memberships in the Configuration database that do not exist within the Collection.

I would suggest that this would be the result of a TFS server that has backed up without the use of a ‘marked transaction log’ and that backup restored at some point. If you have large databases and you don’t use the built in Scheduled Backups tool or the documented process to manually back up Team Foundation Server then you are leaving yourself open for this type of inconsistency.

To find out if your have any orphaned identities then you should run:

Warning Do not make any changes to any of your TFS Databases manually unless specifically instructed by the Product Team. If you do then you can no longer be supported by Microsoft.

FROM    tbl_GroupMembership gm
WHERE   gm.PartitionId = 1
        SELECT  *
        FROM    tbl_Group g
        WHERE   g.PartitionId = 1
            AND g.Id = gm.MemberId                       
        SELECT  *
        FROM    tbl_Identity i
        WHERE   i.PartitionId = 1
            AND i.Id = gm.MemberId

If you get results from this query then you have this problem and you should immediately raise a support ticket with Microsoft to get this fixed.


You need to remove all of the orphaned identities from your server in order to fix this. To achieve that you should work with Microsoft by raising a support ticket and cleaning the instance.  If an invalid backup has been restored there are likely other things that need to happen to get into a supported state and changing the database yourself will not get you there.

Raise a ticket and get your server into a supported state…

    Upcoming Training Opportunities

    These are the next five classes we have, and you can check out our full public schedule of classes.

    Live Virtual PAL Evidence-Based Management Online on 19th June 2023
    19-20 Jun, 2023
    09:00-13:00 BST
    2 half-days
    APS 19th June 2023
    19-22 Jun, 2023
    09:00-13:00 EDT
    4 half-days
    Professional Scrum Product Owner Immersion (PSPO-I) online 3rd July 2023 over 8 weeks
    3 Jul-21 Jul, 2023
    13:00-17:00 BST
    8 weekly half-days
    PSPO-A 10th July 2023
    10-13 Jul, 2023
    09:00-13:00 BST
    4 half-days

    We can deliver any of our courses as private in-house training over Microsoft Teams & Mural. We also recommend training based on your accountabilities or role, you can go directly to recommended courses for Scrum MastersProduct OwnersDevelopers and Agile Leaders.

    Create a conversation around this article

    Share on Facebook
    Share on Twitter
    Share on Linkdin

    Related Courses

    No items found

    Read more

    Martin Hinshelwood Why do you encourage people to follow a certification path in their career journey? I would encourage you to follow a scrum certification path for the same reason that people go to university. The same reason that people do any course or certification. It gets you a foot in …
    Martin Hinshelwood What will you learn on the PSM II course? There are two main things that most scrum masters will learn on the PSM II or Advanced Professional Scrum Master course. That they haven’t been working effectively as a scrum master to date. That they are there to empower and …
    Martin Hinshelwood
    In Scrum Events across the world, I hear repeated the phrase “that’s how agile works” when describing behaviours that are both unprofessional and the very opposite of an agile mindset. These behaviours will inhibit agility and are a result of a lack of understanding of the underlying principles. We need …
    Martin Hinshelwood What is the most common Aha moment people have in a scrum course? It depends on the scrum course they are attending. The content presented in the Applying Professional Scrum (APS) course leads to very different epiphanies when compared to the content presented on an Advanced Professional Scrum Master …


    We believe that every company deserves high quality software delivered on a regular cadence that meets its customers needs. Our goal is to help you reduce your cycle time, improve your time to market, and minimise any organisational friction in achieving your goals.

    naked Agility Limited is a professional company that offers training, coaching, mentoring, and facilitation to help people and teams evolve, integrate, and continuously improve.

    We recognise the positive impact that a happy AND motivated workforce, that has purpose, has on client experience. We help change mindsets towards a people-first culture where everyone encourages others to learn and grow. The resulting divergent thinking leads to many different ideas and opportunities for the success of the organisation.