Share via


Changes Made to an EDM by the Update Model Wizard

The Update Model Wizard enables you to update an Entity Data Model (EDM) after changes have been made to the underlying database. There are two important things to note when you use the Update Model Wizard to update an EDM:

  • The Update Model Wizard overwrites the existing storage model when updating the EDM based on database changes. This means that any custom changes you have made to the storage model will not be reflected in the updated model.

  • 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, associations, and mappings to the conceptual 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).

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 EDM when updating it from the database

Table/view

Added

The new EntityType 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 for any foreign keys that reference the new primary key. Corresponding new associations will be added to the conceptual model. Pre-existing associations (or one or both ends of 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 is removed from a foreign key, then a new association will be created between the remaining end properties.

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.

If an added primary key column 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 EntityType 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.

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.

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.

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 EDM when the Database Changes

Other Resources

Update Model Wizard
Entity Data Model Tools Tasks