Share via


How to: Create and Edit Associations

Associations define relationships between entity types in the Entity Data Model (EDM). Associations are can only have two participating entity types, and each participating entity type in the association is known as an End. There can be multiple associations between entity types. Associations are represented on the design surface as a line that connects two entity types.

Create an Association

Creating an association does the following:

  • Creates a visual representation of the association and adds it to the design surface.

  • Adds navigation properties to the visual representations of the entity types at each end of the association.

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

  • Updates the Mapping Details window.

  • Updates the Model Browser.

Note

After creating an association, you must create the mappings for the association. For more information, see How to: Create and Edit Association Mappings.

To create an association using the New Association dialog box

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

    The New Association dialog box appears.

  2. Fill in the settings for the association:

    • Specify a name for the new association.

    • Select the entities to include in the association from the Entity drop-down list.

    • Select the multiplicity for each entity.

    • Specify the navigation property name for each entity.

  3. Click OK.

To create an association using the Toolbox

  1. Click the Association control in the Toolbox.

  2. Select the entities to include in the association by clicking an entity in the design surface and then clicking another entity on the design surface.

    The New Association dialog box appears.

  3. Fill in the settings for the association:

    • Specify a name for the new association.

    • Select the multiplicity for each entity.

    • Specify the navigation property name for each entity.

  4. Click OK.

To associate a selected entity with another entity

  1. Select an entity in the design surface, point to Add, and select Association.

    The New Association dialog box appears.

  2. Fill in the settings for the association:

    • Specify a name for the new association.

    • Select the entities to include in the association from the Entity drop-down list.

    • Select the multiplicity for each entity.

    • Specify the navigation property name for each entity.

  3. Click OK.

Delete an Association

Associations are deleted by using the ADO.NET Entity Data Model Designer design surface. Deleting an association does the following:

  • Deletes the visual representation of the association from the design surface.

  • Deletes the navigation properties from the visual representations of the entity types at each end of the association.

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

  • Deletes mappings for the association and updates the Entity Mapping Details window.

  • Updates the Model Browser window.

To delete an association

  • Right-click the association and select Delete.

    -or-

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

See Also

Concepts

ADO.NET Entity Data Model Designer Overview

Other Resources

Entity Data Model Tools Tasks