How to: Create and Modify Associations

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

Associations define relationships between entity types in a conceptual model. Associations 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. For more information, see Defining and Managing Relationships (Entity Framework).

Create an Association

Creating an association with the Entity Designer updates the conceptual model content of the .edmx file. For more information about the content of an .edmx file, see .edmx File Overview (Entity Framework). After creating an association, you must create the mappings for the association. For more information, see How to: Create and Edit Association Mappings (Entity Data Model Tools).

To create an association by using the Add Association dialog box

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

    The Add Association dialog box appears.

  2. Fill in the settings for the association.

    NoteNote

    You can choose to not add navigation properties or foreign key properties to the entities at the ends of the association by clearing the Navigation Property and Add foreign key properties to the <entity type name> Entity checkboxes. If you add only one navigation property, the association will be traversable in only one direction. If you add no navigation properties, you must choose to add foreign key properties in order to access entities at the ends of the association. For many-to-many (*:*) and one-to-one (1:1) associations, you cannot add foreign keys to the entities. For more information, see Defining and Managing Relationships (Entity Framework).

  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.

NoteNote

Adding an association with the Toolbox automatically adds navigation properties to the entity types at the ends of the association. Foreign key properties are not added to the entity types. For more information, see How to: Edit and Delete Navigation Properties (Entity Data Model Tools) and Defining and Managing Relationships (Entity Framework).

Delete an Association

Deleting an association as described in the procedure below will only delete the association from your conceptual model. To delete the corresponding association from your storage model, see How to: Delete Objects from the Storage Model (Entity Data Model Tools).

To delete an association

  • Right-click the association on the Entity Designer surface and select Delete.

    -or-

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

See Also

Show:
© 2016 Microsoft