How to: Create and Delete Inheritance Relationships

[This page is specific to the latest version of the Entity Framework. The latest version is available as the 'Entity Framework' NuGet package. For more information, see Entity Framework Releases and Versioning.]

Inheritance enables one entity type to be derived from another entity type in the conceptual model. For example, Employee and Customer types can both inherit from the Contact type. In this case, Contact is called the base type. Employee and Customer are called derived types.

An inheritance relationship is represented on the design surface as a line that connects the base type and the derived type. The connector has a hollow arrow at the end that points to the base type.

Note

The Entity Designer does not allow a type to inherit from itself. That is, the source and target ends must be different.

Create an Inheritance

Creating an inheritance relationship does the following:

  • Adds the inheritance relationship to the design surface.

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

  • Updates the Mapping Details window.

  • Updates the Model Browser window.

To create an inheritance relationship from the design surface

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

    The New Inheritance dialog box appears.

  2. Select the base and derived entity types.

  3. Click OK .

    The inheritance relationship is created.

To create an inheritance relationship using the Toolbox

  1. Select the Inheritance control from the Toolbox .

  2. Click the subtype entity on the designer surface and then click the base type on the designer surface.

    The inheritance relationship is created.

To create an inheritance relationship from a selected entity

  1. Select an entity from the design surface, point to Add , and select Inheritance .

    The New Inheritance dialog box appears. The selected entity is listed as the base entity.

  2. Select the derived entity type.

  3. Click OK .

    The inheritance relationship is created.

To create an inheritance relationship using the Properties window

  1. Select an entity.

  2. From the Properties window, select the base type for the inheritance relationship from the Base Type drop-down list.

    The inheritance relationship is created.

Delete an Inheritance

Deleting an inheritance relationship does the following:

  • Removes the inheritance relationship from the design surface.

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

  • Sets the Base Type property of the derived types to (None) .

  • Updates the Mapping Details window.

  • Updates the Model Browser window.

To delete an inheritance relationship

  • Right-click the inheritance and select Delete .

    -or-

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

See Also

Other Resources

ADO.NET Entity Data Model Designer
Walkthrough: Mapping Inheritance - Table-per-Hierarchy
Walkthrough: Mapping Inheritance - Table-per Type

Build Date:

2013-06-19