// internal static to make it more testable internal static CommandProcessor PrepareCommandsAndIntegrityChecks( ModelBuilderSettings modelBuilderSettings, EditingContext editingContext, EntityDesignArtifact designArtifact) { Debug.Assert(modelBuilderSettings != null, "modelBuilderSettings != null"); Debug.Assert(editingContext != null, "editingContext != null"); Debug.Assert(designArtifact != null, "artifact != null"); var commands = new List <Command>(); if (modelBuilderSettings.NewFunctionSchemaProcedures != null && modelBuilderSettings.NewFunctionSchemaProcedures.Count > 0) { // user selected to create new FunctionImports, but don't create the composable ones as these have already been created by the runtime ProgressDialogHelper.ProcessStoredProcedureReturnTypeInformation( designArtifact, modelBuilderSettings.NewFunctionSchemaProcedures, commands, shouldCreateComposableFunctionImports: false); } else { commands.AddRange(CreateRemoveFunctionImportCommands(designArtifact)); } // for SqlServer and SqlServerCe we need to add integrity checks - see the comment below if (commands.Count > 0 || designArtifact.IsSqlFamilyProvider()) { // set up CommandProcessorContext var cpc = new CommandProcessorContext( editingContext, EfiTransactionOriginator.CreateNewModelId, Resources.Tx_CreateFunctionImport); // We propagate facets by default only for Sql Server or Sql Server CE since for other providers facets in C-Space might be intentionally // out of sync with facets from S-Space and we should not break this. For Sql Server and Sql Server CE facets should be in sync in most cases. if (designArtifact.IsSqlFamilyProvider()) { // Add integrity check to enforce synchronizing C-side Property facets to S-side values PropagateStoragePropertyFacetsToConceptualModel.AddRule(cpc, designArtifact); } return(new CommandProcessor(cpc, commands)); } // no commands or integrity checks to run return(null); }