Model-First Approach

There are two ways of creating ORM models - Model-First approach and Database-First approach. Entity Developer supports both approaches for designing Entity Framework, LinqConnect, NHibernate, Telerik Data Access, and LINQ to SQL models.

Model First Approach in Other Designers

Model-first approach supposes creating entity model (its conceptual part), and then generating context and entity casses and DDL for creating a database schema, based on the the model. For example, it was implemented in that way in EDM Designer in Visual Studio 2010 and later.

However, the database rarely can be created at once, the model often needs to be changed after the database was created. But dropping and re-creating the database is not a choice, because the database may already contain data. Entity Developer solves this problem with Update Database feature.

Our Vision

Update to Database Wizard generates Update script, that makes only necessary changes to the existing model database and retains 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 allows flexible tweaking for the generated names of the tables and columns. You may configure removing and adding of prefixes and suffixes, case and pluralization, etc.

Update to Database Wizard

Mixed Approach

Entity Developer allows you to mix Model-First and Database-First approaches when designing your model. With Update to Database and Update from Database wizards you can easily synchronize your model and database in any direction. For example, you may generate model from the database, then edit it, and apply these changes to the database with Update to Database Wizard.

You can use mapping synchronization with models that were generated from database with Database-First approach. You just need to enable automatic synchronization of the storage part and mapping of the model with its conceptual part in the Model Settings dialog box.

 

Mixed approach

Model Initialization Settings

To automate Model-First development even more, Entity Developer allows you to specify a default set of properties to be added to each new entity in the model automatically. The properties and all their parameters can be specified in the model settings.

Model-First Peculiarities for Entity Framework v1 - v6

Explicit Storage Part

While for most ORMs models just represent entity classes and their mapping to database tables and columns, Entity Framework v1 - v6 models have explicit mapping and storage parts with storage classes, representing database schema.

Storage and Mapping Generation in EDM Designer

When you generate database in Visual Studio's EDM designer, it generates the mapping and storage part based on the conceptual part of the model. However, Visual Studio implementation of Model-First approach does not provide full control over storage and mapping parts of the model. You cannot manually change column data type, rename storage tables, etc, because every time you re-generate a database, the storage and mapping parts are re-generated, and manual changes are lost.

Model-first approach in Entity Framework 4

Storage and Mapping in Entity Developer

To solve the above-mentioned Model First approach problems, Entity Developer offers mapping synchronization - the further Model-First approach improvement.

With mapping synchronization, changes to the conceptual model are automatically applied to its mapping and storage part. For example, when you add a class to the conceptual part, a corresponding table is created in the storage part, and the class is automatically mapped to this table.

Model-first approach in Entity Developer

 

Enabling Mapping synchronization

 

When you add a property into your conceptual model, the corresponding column is created in the storage part. It's data type will be determined by the type of the property in the conceptual part and its facets. Change them in the Properties window or Property Editor, and the corresponding data type changes of the storage part column will be applied. Default values of data type facets for different property types can be set in the model settings.

Even the most complex conceptual part changes are supported - complex types, many-to-many associations, complex hierarchies. All these changes can be automatically reflected in the storage part. However you may make manual changes to the storage part, and they will be preserved when editing conceptual part. With Entity Developer you may create entities from SELECT statements in your storage (Defining Query), that cannot be used with Visual Studio 2010 Model-First implementation.

Besides, when you generate or update the database from your model, all manual changes, made to the storage part, are preserved.