Last week, the Configuration Manager in our company tested to create a collection in Team Foundation Server (TFS for short) 2013 with Update 2. After test, the database of this collection is deleted directly from SqlServer by mistake and there is no backup for it. So an orphan item for this collection is still existed there and have to be removed manually.
First, I try to remove it from Team Foundation Server Administration Console (TfsMgmt.exe). It failed in detach process.
Then, I try to do it with TFSconfig.exe in console mode. I’m pretty sure that’s work in previous version of TFS, maybe 2012. But in 2013 with Update 2, it failed the same as TfsMgmt.
I tried to use a database from another collection by renaming it as the deleted one, or even use a database created with another TFS instance with the same collection name, all failed.
At that time, I turned to MSDN forum. One MVP provided some tables within Tfs_Configuration database. Some deleting operations should be taken there. After that, the collection is removed from the TfsMgmt but it still can be found in Visual Studio at client side.
Finally, I detached all collections and redeployed the whole TFS instance. That works as predictable.
If somebody falls into the same jam, the detachment and redeployment is the only way to correct it, unless you have the backup of that deleted database.
It’s announced that this will be fixed in Update 3 of TFS by Microsoft. A workaround, editing database directly, is provided also. https://connect.microsoft.com/VisualStudio/feedback/details/874523/delete-a-collection-without-related-database-connected-vs2013u2