Fixing reports in exported Visual Studio Online project collection

As Visual Studio Online has gone to general availability (i.e. no more free rides), a lot of people used TFSCONFIG CLOUDIMPORT command to export your TFS projects from Visual Studio Online to the on premises TFS server. That tool makes the export very smooth and actually easy process. But, that's not what we here to talk about. We're here to talk about fixing reports once you have finished the export. CloudImport command only imports TFS content and does not deal with reports at all. So, reports will have to be fixed manually.

First of all, you need to recreate the reports in the Report Server. By the way, you need to upload reports from TFS Scrum template. You can recreate reports using TFS Administrator's Toolkit or all-powerful PowerShell. Once reports are uploaded and warehouse/cube being processed, you will noticed that some of the reports do not work. If you check warehouse processing status, you will notice that an error being thrown during warehouse processing.

System.Data.SqlClient.SqlException: Cannot create compensating record. Missing historic data. Predecessor of work item(s)…

Very confusing error… Points to some kind of confusion between revisions. How can that be? How can the data get "corrupted" during the export? And, more importantly, what data got "corrupted"? To get answer to the last question, try running the following SQL statement against your project collection database:

Select *

FROM [dbo].[WorkItemsLatest] L

JOIN [dbo].[WorkItemsAre] A

ON L.[ID] = A.[ID]

    AND L.[Rev] = A.[Rev]

WHERE L.[Changed Order] <> A.[Changed Order]

   

If the query returns any records, then we have a problem. Most likely all of the returned records have "messed" up revisions. Potentially, that could be a lot of records. To fix the problem, Microsoft provided us with the following SQL query:

UPDATE L

SET L.[Changed Order] = A.[Changed Order]

FROM [dbo].[WorkItemsLatest] L

JOIN [dbo].[WorkItemsAre] A

ON L.[ID] = A.[ID]

    AND L.[Rev] = A.[Rev]

WHERE L.[Changed Order] <> A.[Changed Order]

   

While running the script may have helped us, please RUN THE SCRIPT AT YOUR OWN RISK! AND, PLEASE, DO NOT FORGET TO BACKUP THE PROJECT COLLECTION DATABASE BEFORE YOU RUN THE SCRIPT!!!

After running the script manually refresh warehouse and cube, and you should be fine. Good luck.

UPDATE: See a few more details on how we've fixed the reports after exporting TFS project collection from Visual Studio Online at http://blogs.objectsharp.com/post/2014/06/14/More-on-fixing-reports-after-Visual-Studio-Online-export.aspx