Changes Made to an .edmx File by the Update Model Wizard

The Update Model Wizard enables you to update an .edmx file after changes have been made to the underlying database. The following are important things to note when you use the Update Model Wizard to update an .edmx file:

  • The Update Model Wizard overwrites the existing storage model when updating the .edmx file based on database changes. This means that any custom changes you have made to the storage model will be deleted.

  • The Update Model Wizard makes only additive changes to the conceptual model and mappings. This means that when a new object is added to the database, the Update Model Wizard adds corresponding entities and associations to the conceptual model, and maps them to the storage model. However, if objects are removed from the database the Update Model Wizard does not remove the corresponding entities or associations from the conceptual model (corresponding mappings are removed). For information about removing objects from the storage model without running the Update Model Wizard, see How to: Delete Objects from the Storage Model (Entity Data Model Tools).

  • If the Pluralize or singularize generated object names checkbox is enabled (on the Add tab of the wizard), the wizard will attempt perform the following actions:

    • Make all entity type names singular.

    • Make all entity set names plural.

    • For each navigation property that returns at most one entity, make the name singular.

    • For each navigation property that returns more than one entity, make the name plural.

    The Entity Data Model Wizard applies English language rules for singulars and plurals by creating a PluralizationService and passing it to an EntityModelSchemaGenerator.

  • If the Include foreign key columns in the model checkbox is enabled (on the Add tab of the wizard), the wizard will include properties on newly generated entity types that correspond to foreign key columns in the database. For more information, see Defining and Managing Relationships (Entity Framework).

Changes to a Conceptual Model When Updating from the Database

The following table provides details about how the Update Model Wizard modifies the conceptual model when a change has been made to a database object.

Database object Change to object in database Changes made to the conceptual model when updating it from the database

Table/view

Added

The new entity type and the corresponding associations and mappings are added to the conceptual model.

Deleted

The table or view is removed from the storage model. All mappings to the table are deleted. If the table or view had one or more columns that stored keys for a foreign key relationship, mappings for the corresponding associations are deleted.

Renamed

Renaming a table or view has the same effect on the conceptual model and mappings as deleting the table/view with the old name and adding a table/view with the new name.

Primary key changed

If columns are added to the primary key of the table or view, associations will be added to the conceptual model for any foreign keys that reference the new primary key. Corresponding new associations will be added to the conceptual model. Pre-existing associations that were based on the old primary key (or one or both ends of these pre-existing associations) will no longer be mapped.

NoteNote
Unmapped associations will still appear on the Designer surface and will cause validation errors. To correct the validation errors, delete unmapped associations or re-map them.

If a column is removed from a primary key, you will have to remove the key designation of the corresponding entity property.

If a column that was present as an entity property is added to the primary key, the entity property must be made into an entity key. For information about how to modify properties, see How to: Create and Modify Scalar Properties (Entity Data Model Tools).

If an existing column is added to the primary key and was previously mapped to an association (rather than to an entity property), a corresponding new entity property will be created.

Column

Added

The corresponding entities are updated with matching properties and mappings. If the corresponding types are part of an inheritance hierarchy, only the entity type that is closest to the root of the hierarchy and that is mapped to the affected table is updated with matching properties. This prevents child entities in the hierarchy from defining the same properties as their ancestors.

Deleted

Mappings to the column are deleted.

Renamed

Renaming a column has the same effect on the conceptual model as deleting the column with the old name and adding a column with the new name.

If you rename a column that is part of a foreign key constraint, a new association and the required mappings are added to the conceptual model if all necessary entity types are present.

Definition altered

No changes are made to the conceptual model or mappings. The model might have to be updated manually if the column type is changed so that the corresponding entity property type is incompatible. For information about how to modify properties, see How to: Create and Modify Scalar Properties (Entity Data Model Tools).

Foreign key

Added

A new association and required mappings are added to the conceptual model if all necessary entity types are present.

Deleted

No changes are made to the conceptual model or mappings.

Renamed

No changes are made to the conceptual model or mappings.

Stored procedure

Added

No changes are made to the conceptual model or mappings. The stored procedure can be manually added to the conceptual model as a Function Import. For more information, see How to: Import a Stored Procedure (Entity Data Model Tools).

Deleted

Mappings to the stored procedure are deleted. If a Function Import was mapped to the stored procedure, the Function Import must be deleted or mapped to a different stored procedure. If the insert, update, or delete behavior of an entity type was mapped to the stored procedure, the mappings will be deleted.

Renamed

Mappings to the stored procedure for any Function Import or insert, update, or delete behavior of an entity type are deleted. This has the same effect on the conceptual model as deleting the stored procedure with the old name and adding the stored procedure with the new name. A new Function Import must be created for the renamed stored procedure or the original Function Import must be remapped to the renamed stored procedure.

Definition Altered

If parameters are added or removed from the stored procedure, all mappings to the stored procedure become invalid. If a Function Import was mapped to the stored procedure, the Function Import must be deleted and recreated. If the insert, update, or delete behavior of an entity type was mapped to the stored procedure, the behavior might have to be remapped.

See Also

Tasks

How to: Update an .edmx File when the Database Changes (Entity Data Model Tools)

Other Resources

Update Model Wizard (Entity Data Model Tools)
Entity Data Model Tools Tasks