title: Dynamics 365 (on-premises) v8.2 upgrade to v9 fails
body: <p>I am trying to upgrade Dynamics 365 version 8.2.3 to version 9.0, but have some problems with it.<br/>
  I've tried two scenarios on my test server:<br/></p>
  
  <ol>
  <li><p>Created backup of my real CRM database (XXXXXX_MSCRM)<br/>
  Restored it on the test server.<br/>
  Installed version 9.0 on the test server. Installed the latest update for it.<br/>
  Did Import Organization on restored database (XXXXXX_MSCRM) via Deployment Manager. It failed.<br/>
  As a result, importing failed with this exception: </p>
  
  <p><em>System.Exception: Error.ActionFailed Microsoft.Crm.Tools.Admin.InstallDatabaseUpdatesAction ---> Microsoft.Crm.CrmException: Error in Action: Bin\Microsoft.Crm.Setup.DiffBuilder.dll:UpgradeSystemAndMetadataDiffIndexManagementDataWithDelete on attempt 3. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: The constraint 'PK_topicmodelBase' is being referenced by table 'TopicModelExecutionHistoryBase', foreign key constraint 'topicmodel_topicmodelexecutionhistory'.</em></p></li>
  <li><p>Created backup of my real CRM database (XXXXXX_MSCRM)<br/>
  Restored it on the test server.<br/>
  Installed version 8.2 on the test server.<br/>
  Did Import Organization on restored database (XXXXXX_MSCRM) via Deployment Manager. It succeeded.<br/>
  Installed the latest update for version 8.2. It succeeded.<br/>
  Installed/Upgraded Dynamics 365 to version 9.0. It failed.<br/>
  During the installation it also tried to upgrade Organization version to 9.0 and failed. So, server version 9.0 is installed, but my organization is in Failed state.<br/>
  Explored the log file and got this exception: </p>
  
  <p><em>System.Exception: Action Microsoft.Crm.Tools.Admin.InstallCrmSystemConvertedSolutionsAction failed. ---> Microsoft.Crm.PackageDeployment.PackageDeployerException: Package msdynce_MarketingSales failed to install on attempt 1.
  System.AggregateException: One or more errors occurred. ---> Microsoft.Crm.MultiTenantPackageDeployment.PackageDeployerImportException: PackageDeployerWrapper: Import Failed status encountered. Details: Failed to load solution Marketing Sales Patch, version: 9.0.4.3602</em></p>
  
  <p>and also a bunch of this kind of inner exceptions:</p>
  
  <p><em>Error  : The AttributeLookupValue (Id=81cde1dc-2241-db11-898a-0007e9e17ebd) entity or component has attempted to transition from an invalid state: ComponentStateName: Solution; ComponentOperation: Delete; ComponentSolutionType: Active; SolutionOperationContext: MoveSystemComponentToFirstPartySolution; IsProtected: False; FinalComponentState: Publish.</em></p></li>
  </ol>
  
  <p>Did anyone faced with such a problems during the upgrade process?</p>