Updating Model from Database

Update From Database Wizard allows updating model from database in a fast and convenient way. Manual changes to the model are preserved where possible.

The wizard detects all the database changes that can affect the model, e.g. created and deleted tables and views, their columns and foreign keys, column datatype changes, created and deleted stored procedures and functions, changes to their parameters etc.

When updating Entity Framework models from database, the database structure is compared to the Storage model. All changes are reflected in the Conceptual model when synchronizing. However, for example, if you have deleted a class from the conceptual model but the corresponding table still exists in the storage model, it is not detected as a change.

 

ExpandedToggleIcon        Updating Model from Database

To update model from database, perform the following steps.

1.Right-click the empty space in the diagram area and select Update Model From Database from the popup menu. The first page of Update From Database Wizard is displayed.

Images_UpdateFromDB1

2.Select the Recreate Model check box, if necessary, to clear the model and create it anew without deleting and then adding the file of the model.
3.Click the Next button. The Choose schemas page of the wizard is displayed.

Images_UpdateFromDB2

4.Select schemas to be compared with the model and click the Next button. The Choose change actions page of the wizard is displayed.

Images_UpdateFromDB3

5.Select the Group by schemas check box to group changed database objects by schemas, if necessary.
6.Select database objects and separate changes to be synchronized.
 
In case you choose not to apply changes to some column or constraint, Entity Developer will 'remember' it and next time will not offer to apply changes to this object, i.e. in the Choose Actions tree the object will be deselected by default.
 
Each node of the object tree corresponding to database object available for update has a remark which describes an action raised between this object and the corresponding model entity. The following types of actions are available:
a.Added - means that this object isn't presented in the model. It will be added to the model after wizard finishing.
b.Dropped - means that this object isn't presented in the database. It will be dropped from the model after wizard finishing.
c.Changed - means some properties of this object differ from the corresponding database object fields. Model object property set will be changed.
d.Renamed - means that objects in the database and in the model have different names. This type of changes is not always detected automatically during the process of comparison of database metadata and metadata built on the basis of the model. For the renamed objects to be detected, they must conform to certain rules. Metadata comparison is implemented in two steps. In the first step equivalents are looked for, having exactly the same number of columns and foreign keys, and the columns themselves match as well; if no equivalents are found, then similar objects are looked for according to the same rules, but columns must match only in the matter of names. If identical objects are found, similar objects will not be looked for. If objects are not detected as renamed automatically, they are displayed as a pair of dropped/created objects. You need to select such pair, right-click the selection, and choose Resolve Renamed from the popup menu to mark the objects as renamed. In order to cancel renaming, right-click the object marked as Renamed and select the Cancel Renaming option.

Right-click the root nodes to call the context menu and check/uncheck all added/dropped/changed objects.

7.Click the Next button.
8.In the final page of the wizard click Finish.

Now the database and the storage model are synchronized.

 


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.