Are there some pitfalls when I import organization with OptimizeOrgImport=1? How this optimization works internally?
Use case:
- Import organization, say “test”. (works fine)
- Import another copy of this organization, say “test2” (fails when updating users)
- Set OptimizeOrgImport=0 and import “test2” (fine again!)
Log of the step 2:
14:46:22| Info| Import Organization (test2)
14:46:22| Info| Update Organization...
14:48:20| Info| Update Users...
14:48:44| Error| Import Organization (Name=test2, Id=5b6bf441-650c-e211-b194-00185d111162) failed with Exception:
System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
at System.Data.SqlClient.SqlConnection.GetOpenConnection(String method)
at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
at Microsoft.Crm.CrmDbConnection.SetTransactionIsolationLevel(IsolationLevel il)
at Microsoft.Crm.CrmDbConnection.Dispose(Boolean disposing)
at Microsoft.Crm.SqlExecutionContext.Dispose(Boolean disposing)
at Microsoft.Crm.SqlExecutionContext.Dispose()
at Microsoft.Crm.Tools.Admin.ImportOrganizationInstaller.Import(Guid organizationId, String organizationUniqueName, String organizationFriendlyName, String sqlServerName, String databaseName, Uri reportServerUrl, String privilegedUserGroupName, String sqlAccessGroupName, String userGroupName, String reportingGroupName, String privilegedReportingGroupName, ICollection`1 users, MultipleTenancy multipleTenancy)
Thank you in adavance.
With the OptimizeOrgImport setting set to 1 you have to take following into account:
See http://support.microsoft.com/kb/977867/en
Each organization database contains a table
[dbo].[OrganizationBase]. One of its columns isOrganizationId. This GUID will identify the organization.If you make a backup of the Organization database on the CRM Environment Prod and restore it on the CRM Environment Test, it will keep its ID. If you later restore test2 it has the same ID as the one you have imported earlier.
OptimizeOrgImport was introduced with Rollup 8 and introduced a new import process. I assume that the old import process (OptimizeOrgImport = 0) will also change the ID of the organization. Therefore you won’t have the issue with the old import process.