Inheritance: Microsoft.Data.Entity.Design.Model.Commands.Command
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(
                _conceptualEntityType != null && _function != null,
                "InvokeInternal is called when _conceptualEntityType or _function is null");
            if (_conceptualEntityType == null ||
                _function == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _conceptualEntityType or _function is null");
            }

            // see if we have the ETM we need, if not create it
            var entityTypeMapping = ModelHelper.FindEntityTypeMapping(
                cpc,
                _conceptualEntityType,
                EntityTypeMappingKind.Function,
                true);

            Debug.Assert(entityTypeMapping != null, "Failed to create the EntityTypeMapping to house this item");
            if (entityTypeMapping == null)
            {
                throw new ParentItemCreationFailureException();
            }

            // if we created a new ETM, then we'll need to also create the ModificationFunctionMapping
            if (entityTypeMapping.ModificationFunctionMapping == null)
            {
                entityTypeMapping.ModificationFunctionMapping = new ModificationFunctionMapping(entityTypeMapping, null);
                XmlModelHelper.NormalizeAndResolve(entityTypeMapping.ModificationFunctionMapping);
            }
            Debug.Assert(
                entityTypeMapping.ModificationFunctionMapping != null,
                "Failed to create the ModificationFunctionMapping node to house this item");
            if (entityTypeMapping.ModificationFunctionMapping == null)
            {
                throw new ParentItemCreationFailureException();
            }

            // now go and actually create the item
            if (_type == ModificationFunctionType.Insert)
            {
                _modificationFunction = new InsertFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.InsertFunction = _modificationFunction as InsertFunction;
            }
            else if (_type == ModificationFunctionType.Update)
            {
                _modificationFunction = new UpdateFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.UpdateFunction = _modificationFunction as UpdateFunction;
            }
            else if (_type == ModificationFunctionType.Delete)
            {
                _modificationFunction = new DeleteFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.DeleteFunction = _modificationFunction as DeleteFunction;
            }
            Debug.Assert(_modificationFunction != null, "Failed to create the new function mapping");
            if (_modificationFunction == null)
            {
                throw new ItemCreationFailureException();
            }

            // set the function into the function mapping
            _modificationFunction.FunctionName.SetRefName(_function);

            // set the RowsAffectedParameter
            var cmd = new SetRowsAffectedParameterCommand(_modificationFunction, _rowsAffectedParameter);

            CommandProcessor.InvokeSingleCommand(cpc, cmd);

            XmlModelHelper.NormalizeAndResolve(_modificationFunction);
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(
                _conceptualEntityType != null && _function != null,
                "InvokeInternal is called when _conceptualEntityType or _function is null");
            if (_conceptualEntityType == null
                || _function == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _conceptualEntityType or _function is null");
            }

            // see if we have the ETM we need, if not create it
            var entityTypeMapping = ModelHelper.FindEntityTypeMapping(
                cpc,
                _conceptualEntityType,
                EntityTypeMappingKind.Function,
                true);
            Debug.Assert(entityTypeMapping != null, "Failed to create the EntityTypeMapping to house this item");
            if (entityTypeMapping == null)
            {
                throw new ParentItemCreationFailureException();
            }

            // if we created a new ETM, then we'll need to also create the ModificationFunctionMapping
            if (entityTypeMapping.ModificationFunctionMapping == null)
            {
                entityTypeMapping.ModificationFunctionMapping = new ModificationFunctionMapping(entityTypeMapping, null);
                XmlModelHelper.NormalizeAndResolve(entityTypeMapping.ModificationFunctionMapping);
            }
            Debug.Assert(
                entityTypeMapping.ModificationFunctionMapping != null,
                "Failed to create the ModificationFunctionMapping node to house this item");
            if (entityTypeMapping.ModificationFunctionMapping == null)
            {
                throw new ParentItemCreationFailureException();
            }

            // now go and actually create the item
            if (_type == ModificationFunctionType.Insert)
            {
                _modificationFunction = new InsertFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.InsertFunction = _modificationFunction as InsertFunction;
            }
            else if (_type == ModificationFunctionType.Update)
            {
                _modificationFunction = new UpdateFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.UpdateFunction = _modificationFunction as UpdateFunction;
            }
            else if (_type == ModificationFunctionType.Delete)
            {
                _modificationFunction = new DeleteFunction(entityTypeMapping.ModificationFunctionMapping, null);
                entityTypeMapping.ModificationFunctionMapping.DeleteFunction = _modificationFunction as DeleteFunction;
            }
            Debug.Assert(_modificationFunction != null, "Failed to create the new function mapping");
            if (_modificationFunction == null)
            {
                throw new ItemCreationFailureException();
            }

            // set the function into the function mapping
            _modificationFunction.FunctionName.SetRefName(_function);

            // set the RowsAffectedParameter
            var cmd = new SetRowsAffectedParameterCommand(_modificationFunction, _rowsAffectedParameter);
            CommandProcessor.InvokeSingleCommand(cpc, cmd);

            XmlModelHelper.NormalizeAndResolve(_modificationFunction);
        }