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 and LINQ to SQL models. It supports Model-First approach for Entity Framework 1, 4, 5, 6 and Visual Studio 2008, 2010, 2012, 2013, 2015, 2017, and 2019.

ExpandedToggleIcon        Model First in EDM Designer in Visual Studio 2010 - 2019

Model-first approach supposes creating entity model (its conceptual part), and then generating storage, mapping, and DDL for creating a database schema, based on the storage part of the model. It was implemented in that way in EDM Designer in Visual Studio 2010.

images_vs-diagram

However, the database can rarely 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 the Update Database feature.

ExpandedToggleIcon        Our Vision

images_update-to-database

Update to Database Wizard generates the 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.

However, even with Update to Database Wizard, 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.

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

 

 

 

ExpandedToggleIcon        Mapping Synchronization

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.

images_our-diagram

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.

When designing an Entity Framework model, you may find useful the Create Storage and Mapping option, that allows you to manually create and recreate a storage part object from a conceptual model object, and the corresponding mapping between them.

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 the 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 and Visual Studio 2012 Model-First implementation.

Model-First peculiarities in NHibernate, LINQ to SQL and LinqConnect Models

images_linq-properties

While Entity Framework models have explicit storage parts, NHibernate and LINQ models don't have the one. In LINQ models, Entity Developer considers the Source property of entity, and Source and Server Data Type properties of entity property as the storage part. The Source property specifies the corresponding table or column name in the database, and Server Data Type property specifies the corresponding column data type. The storage part of NHibernate models in Entity Developer is represented by the Schema and Table properties for entity, and the Column property containing the set of the corresponding column settings for entity property.

 

 

 

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.