How to: Add and Edit Referential Constraints

[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.]

This topic describes how to add a referential constraint to a conceptual model with the Entity Designer. For more information about referential constraints, see ReferentialConstraint Element (CSDL).

If there is a referential constraint on an association in a conceptual model, the Create Database Wizard propagates the referential constraint to the database. For more information, see Generate Database Wizard and Database Generation Rules.

Adding or Editing a Referential Constraint in a Conceptual Model

When you use the Entity Designer to add or edit a referential constraint in a conceptual model, the Entity Designer adds or modifies a ReferentialConstraint element in the CSDL content of the .edmx file.

To add or edit a referential constraint in a conceptual model

  1. Double-click the association that you want to edit.

    The Referential Constraint dialog box appears.

  2. From the Principal drop-down list, select the principal entity in the referential constraint.

    The entity's key properties are added to the Principal Key list in the dialog box.

  3. From the Dependent drop-down list, select the dependent entity in the referential constraint.

  4. For each principal key that has a dependent key, select a corresponding dependent key from the drop-down lists in the Dependent Key column.

  5. Click OK .

See Also

Build Date: