Before we start looking at these development styles in detail, let's try to do a comparative analysis of these styles. It will help us in understanding these styles in detail.
In a Database First approach, the main benefit that the developers have is that if the database is created, they will spend very little time writing the data access layer. The EDM can be created from the database and then we can change it as per our application needs; our data access layer is ready to use. Here are a few scenarios where the Database First approach is very useful:
When we are working with a legacy database.
When we are working in a scenario where the database design is being done by another team of DBAs, and once the database is ready, the application development starts.
When we are working on a data centric application, that is, the application domain model is the database itself, and it is being changed frequently to cater to new requirements. For instance, when the tables are being updated regularly and new columns are being added to it frequently then we can simply use this approach, and the application code will not break. We simply have to write the code to cater to the newly added columns.
Similar to the Database First approach, in the Model First approach, we ultimately end up with the EDM. Using this EDM, we can create our conceptual model and the database. The only reason to choose the Model First approach is that we really want to use the Visual Entity Designer. There is no other strong reason to choose this approach over the other two.
The Code First approach is usually helpful where all the business logic is implemented in terms of classes, and the database is simply being used as a persistence mechanism for these models. Here are a few reasons why one might want to choose the Code First approach:
The database is simply a persistence mechanism for the models, that is, no logic is in the database.
Full control over the code, that is, there is no auto-generated model and context code.
The database will not be changed manually. The model classes will always change and based on this, the database should change itself.