protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // make sure that there isn't an ETM of this kind already
            var entityTypeMapping = ModelHelper.FindEntityTypeMapping(cpc, _entityType, _kind, false);

            Debug.Assert(entityTypeMapping == null, "We are calling CreateEntityTypeMappingCommand and there is already one of this Kind");
            if (entityTypeMapping != null)
            {
                _created = entityTypeMapping;
                return;
            }

            // see if we can get the EntitySetMapping for our entity (if we weren't passed it)
            if (_entitySetMapping == null)
            {
                var ces = _entityType.EntitySet as ConceptualEntitySet;
                Debug.Assert(ces != null, "_entityType.EntitySet should be a ConceptualEntitySet");

                // find the EntitySetMapping for this type (V1 assumption is that there is only ESM per ES)
                EntitySetMapping esm = null;
                foreach (var depMapping in ces.GetAntiDependenciesOfType <EntitySetMapping>())
                {
                    esm = depMapping;
                    break;
                }

                _entitySetMapping = esm;
            }

            // if we still don't have an ESM, create one
            if (_entitySetMapping == null)
            {
                var cmd = new CreateEntitySetMappingCommand(
                    _entityType.Artifact.MappingModel().FirstEntityContainerMapping,
                    _entityType.EntitySet as ConceptualEntitySet);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
                _entitySetMapping = cmd.EntitySetMapping;
            }
            Debug.Assert(
                _entitySetMapping != null,
                "_entitySetMapping should not be null - we have been unable to find or create an EntitySetMapping");

            // create the ETM
            var etm = new EntityTypeMapping(_entitySetMapping, null, _kind);

            etm.TypeName.SetRefName(_entityType);
            _entitySetMapping.AddEntityTypeMapping(etm);

            XmlModelHelper.NormalizeAndResolve(etm);

            _created = etm;
        }