I have upgraded my Sitecore solution from 7.5 to 8.1 update 1. When trying to rebuild the Reporting database, I am getting the following error in the log files:

<!-- language: none -->

    7084 2016:12:18 05:26:24 ERROR Exception when executing agent aggregation/rebuildAgent
    Exception: System.InvalidOperationException
    Message: Cannot initialize when there is work to do
    Source: Sitecore.Kernel
       at Sitecore.Diagnostics.Assert.IsFalse(Boolean condition, String message)
       at Sitecore.Analytics.RangeScheduler.MongoDbRangeMap.Initialize(Guid left, Guid right, Int64 count)
       at Sitecore.Analytics.Automation.Aggregation.Data.Processing.AutomationHistoryAggregatorManager.Start(List`1 targetProvidersConfigPaths)
       at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at Sitecore.Analytics.Aggregation.History.ReportingStorageManager.ProcessRebuild()
       at Sitecore.Analytics.Core.BackgroundService.Run()

Any ideas how to solve this?