Development Approach


Entity Framework provides three different approaches to deal with the model, and each one has its own pros and cons.

Model First

In the Model First approach, the database model is created first using the ORM designer in Visual Studio. Once the model that consists entities and relationships has been designed, the database will be generated from the model.

Database First

In the Database First approach, we creats the entity framework from an existing database. We use all other functionality, such as the model/database sync and the code generation. Create the ADO.Net Entity Data Model (EDM) using the Generate from Database option.

Code First

In Code First Approach, we have to create the classes first and then can generate the database from the classes directly. In code first, we don’t use the Entity Designer (to edit .edmx files).

 

When to use which approach

1. The Model First approach is preferable when creating the model using the ORM designer.

2. With an existing database, we can use the Database First approach to create the Entity Framework objects using existing database. Any modification to the Model using the ORM designer requires syncing back to the database.

3. In Code First approach, the database is used for storing the data only. The database structure is defined by various classes. The basic advantage of the Code First approach is that same class is used for defining the database table structure and business object. Any changes in the class affect both the business object and the database table.

Also, we can deploy the Code First approach used project into Azure with Azure Storage, classes can be reused to define the Azure Storage objects.

Praesent mattis

Pellentesque viverra vulputate enim. Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum id, elementum congue, nibh. Suspendisse dictum porta lectus. Donec placerat odio vel elit.

Read More