Synchronizing Model and Database Data

Entity Developer implements synchronization of model and database data via the Update From Database and Update To Database wizards. The general information about their functionality is provided below.

Updating Model from Database

When developing a model using the Database-First approach you may need to make changes to your database and then reflect these changes in your model. With Entity Developer, you can use Update From Database Wizard that allows synchronizing your model with the database for LinqConnect, NHibernate and Entity Framework in a fast and convenient way.

In Visual Studio, the standard Update Wizard performs such updating for Entity Framework models. However, when updating model, the wizard resets all manual changes to the model. Unlike the standard Visual Studio Update Wizard, Entity Developer Update From Database Wizard tries to preserve manual changes to the model 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.

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.

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.

Updating Database from Model

When developing a model using the Model-First approach, the necessity arises to make only certain changes to the existing database and retain data, if possible. For these purposes, the Update To Database wizard is used.

The wizard detects changes inside of the entities and generates scripts for updating database with applying only necessary changes and keeping the data, if possible. The database does not need to be re-created. The wizard displays the tree of the changed objects and their changes, allowing you to choose which objects need to be synchronized, specify the renamed objects, etc. Even changes inside entity are detected and result in ALTER statements, the table doesn't need to be dropped and created again.

Entity Developer offers you a functionality for synchronization of your database with storage part of your model. Storage part can be synchronized with the conceptual model accordingly. In the process of development, you can enable and disable automatic synchronization of the storage part and mapping with the conceptual part.

note Note

Entity Developer also has a console application that allows generating scripts, creating or updating database from model, using console commands.

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.