src/Misc/EFTools/EntityDesignModel/Commands/CreateEntityTypeCommand.cs
/// <summary>
///     This helper function will create an entity type and set, along with one key property
///     in the entity type, using default names.  For instance, the second time this is called you'll
///     get an entity called "EntityType2", etc.
///     This only creates these in the conceptual model.
///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
///     and the caller of this helper method must commit it to see these changes commited.
/// </summary>
/// <param name="cpc"></param>
/// <returns>The new EntityType</returns>
This helper function will create an entity type and set, along with one key property
in the entity type, using default names.  For instance, the second time this is called you'll
get an entity called "EntityType2", etc.
This only creates these in the conceptual model.
NOTE: If the cpc already has an active transaction, these changes will be in that transaction
and the caller of this helper method must commit it to see these changes commited.
This helper function will create an entity type and set along with one key property in the entity type using default names . For instance the second time this is called you ' ll get an entity called " EntityType2 " etc . This only creates these in the conceptual model . NOTE : If the cpc already has an active transaction these changes will be in that transaction and the caller of this helper method must commit it to see these changes commited .
internal static EntityType CreateEntityTypeAndEntitySetWithDefaultNames(CommandProcessorContext cpc)
        {
            var service = cpc.EditingContext.GetEFArtifactService();
            var artifact = service.Artifact;
            var model = artifact.ConceptualModel();
            if (model == null)
            {
                throw new CannotLocateParentItemException();
            }
            var entityName = ModelHelper.GetUniqueNameWithNumber(typeof(EntityType), model, Resources.Model_DefaultEntityTypeName);
            var entitySetName = ModelHelper.GetUniqueName(
                typeof(EntitySet), model.FirstEntityContainer, ModelHelper.ConstructProposedEntitySetName(artifact, entityName));
            EntityType entityType = CreateConceptualEntityTypeAndEntitySetAndProperty(
                cpc, entityName, entitySetName, true,
                Resources.Model_IdPropertyName, ModelConstants.Int32PropertyType, ModelConstants.StoreGeneratedPattern_Identity, false, true);
            return entityType;
        }
internal static EntityType CreateEntityTypeAndEntitySetWithDefaultNames ( CommandProcessorContext cpc ) { var service = cpc . EditingContext . GetEFArtifactService ( ) ; var artifact = service . Artifact ; var model = artifact . ConceptualModel ( ) ; if ( model == null ) { throw new CannotLocateParentItemException ( ) ; } var entityName = ModelHelper . GetUniqueNameWithNumber ( typeof ( EntityType ) , model , Resources . Model_DefaultEntityTypeName ) ; var entitySetName = ModelHelper . GetUniqueName ( typeof ( EntitySet ) , model . FirstEntityContainer , ModelHelper . ConstructProposedEntitySetName ( artifact , entityName ) ) ; EntityType entityType = CreateConceptualEntityTypeAndEntitySetAndProperty ( cpc , entityName , entitySetName , true , Resources . Model_IdPropertyName , ModelConstants . Int32PropertyType , ModelConstants . StoreGeneratedPattern_Identity , false , true ) ; return entityType ; }
This helper function will create an entity type and set, along with one key property
in the entity type, using default names.
This helper function will create an entity type and set along with one key property in the entity type using default names .
// the model that we want to add the entity to // derive some default names // go create it
The new EntityType
The new EntityType
cpc
CommandProcessorContext
None