Recently we were in process for starting upgrade project and we have been doing multiple imports from 2011 environment to 2013 Development server. The reason we approached to do an import is to have some data along side customizations.
Recently while importing one such instance, we got the following error on log:
InnerException:
Microsoft.Crm.CrmException: Database having version 6.1.1.132 is not supported for upgraded.
at Microsoft.Crm.Setup.Database.DatabaseInstaller.ValidateUpgrade(CrmDbConnection connection, ReleaseInfo releaseInfo, Boolean throwIfNotUpgradeable)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.ValidateUpgrade(DatabaseUtility database, ReleaseInfo releaseInfo, Boolean throwIfNotUpgradeable)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.installInternal(Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase, Boolean isInstall)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase)
at Microsoft.Crm.Tools.Admin.InstallDatabaseAction.Do(IDictionary parameters)
at Microsoft.Crm.Setup.Shared.CrmAction.ExecuteAction(CrmAction action, IDictionary parameters, Boolean undo)
This seemed to be a very generic error and did not seem like any CRM specific one. On checking further it came up to be a case where the CRM organisation id we were trying to import was already part of configuration database (MSCRM_Config) .
Error Resolution:
Although it looks to be a big query and very complex work, in short it just updates all organisation id in your database to a new value prior to import.
Steps for Error resolution are as below:
1. Backup original database
2. Restore the original database to new one
3. Run this script on new database:
SELECT ‘ALTER TABLE ‘+QUOTENAME(name)+’ NOCHECK CONSTRAINT ALL’
FROM sysobjects WHERE xtype=’U’ and uid=1
declare @newid uniqueidentifier
select @newid = newid()
SELECT
‘Update ‘ + c.TABLE_SCHEMA + ‘.’ + c.TABLE_NAME + ‘ set ‘ + c.COLUMN_NAME +’ =”’ + +cast(@newid as varchar(40))+””
FROM INFORMATION_SCHEMA.Columns c
INNER JOIN INFORMATION_SCHEMA.Tables t
ON c.TABLE_NAME = t.TABLE_NAME
AND t.TABLE_TYPE = ‘BASE TABLE’
WHERE DATA_TYPE = ‘uniqueidentifier’ and column_name=’organizationid’
SELECT ‘ALTER TABLE ‘+QUOTENAME(name)+’ CHECK CONSTRAINT ALL’
FROM sysobjects WHERE xtype=’U’ and uid=1
4. Run the Step 3 results on new database
5. Import organization from new database with different name than original organization
Hope it helps!