Code First vs. Database First vs. Model First Approach

In this blog, you will see the logical differentiation between following approach which is used to handle database activity using entity framework.

Code First Approach

It is very popular approach between MVC programmers. It has full control over the code rather than database activity. Using this approach we can do all the database activity from the code. So, we can say manual changes to database have been lost to use this and everything is depended on the code.

In this you need to create POCO entities as data model.

Database First Approach

If you have already a designed database and you don’t want to do extra effort then you can go with this approach. If your database is ready then Entity Framework will complete his duty and create POCO entities for you with T4 template.

You can modify the database manually and update model from database. So, we can say, entity framework is able to create your model classes based on tables and columns from relational database.

 

Model First Approach

In this approach, you need to draw your model first and let workflow to decide to generate your database. If you are going to work with small project then it will be best. You cannot make manual change into database because of you don’t have command on database, but you can made the changes into model classes.

So, using the entity framework designer, you can create your model classes and based on your model classes your database will be generated.

Hope you enjoyed this blog.

Ebook Download
View all
Learn
View all