Export (0) Print
Expand All

How to: Create and Modify Entity Types (Entity Data Model Tools)

This topic describes how to create and modify entity types in the ADO.NET Entity Data Model Designer (Entity Designer).

Create an Entity Type

When you create an entity type, the Entity Designer does the following:

  • Creates a visual representation of the entity type on the design surface.

  • Modifies the part of the .edmx file that defines the conceptual data model.

  • If the new type is a derived type, sets the base type. This includes the appropriate inheritance connector.

  • If the new type is not a derived type, creates a key property of the specified name and type.

  • Updates the Mapping Details window.

  • Updates the Model Browser window.

To create an entity type using the New Entity dialog box

  1. Right-click an empty area of the design surface, point to Add, and then click Entity.

    The New Entity dialog box appears.

  2. Fill in the settings for the new entity type:

    • Specify a name for the entity type. The name must be unique within the conceptual model namespace. For more information, see .edmx File Overview (Entity Framework).

    • Select the base type for the entity type. If you want the new entity type to derive from another type, select the base type from the pull-down list; otherwise, set this field to None.

    • Specify a name for the entity set. If the new entity is a derived entity, this field is not enabled.

    • Specify the key property name and type. The key property is used to find unique instances of the entity type. These fields are enabled when Base type is set to None.

  3. Click OK.

    The designer creates an entity type.

To create an entity type using the Toolbox

  1. From the Toolbox, drag the Entity control to an empty area of the design surface.

    A new entity type is displayed on the design surface.

  2. Edit properties for the new entity type in the Properties window.

Modify an Entity Type

You can modify entity types by using the Properties window.

To modify an entity type

  1. Select the entity.

    The entity type information is displayed in the Properties window.

  2. Make any changes in the Properties window.

To edit a property name using the design surface

  1. Select the entity type and then click the property name.

    The property name becomes an editable field.

  2. Update the property name.

Delete an Entity Type

Deleting an entity type does the following:

  • Deletes the visual representation of the entity type from the design surface.

  • Modifies the part of the .edmx file that defines the conceptual data model.

  • Sets the Base Type property of all the entity type's derived types to (none) and deletes the appropriate inheritance connectors.

  • Deletes all associations where the <End> element includes the deleted entity type. This will also delete the appropriate navigation properties.

  • Deletes mappings for the entity type and updates the Mapping Details window.

  • Updates the Model Browser window.

To delete an entity type

  • Select the entity type, right-click, and select Delete.

    -or-

  • Select one or more entities and press the DELETE key.

See Also

Show:
© 2014 Microsoft