Database first vs Code First in Entity Framework

1_J8khcB_mGxI_TTVTaTUqsg.png

There are two workflows that the Entity Framework uses. The traditional way is to design database tables first. And then Entity Framework generates the corresponding domain classes. This method is called the Database first (DB first) approach.

Capture

The other way is the opposite direction. So we start from domain classes and have Entity Framework generate the database tables. Capture

This approach is better. Because

  • It increases productivity. You can create the database and tables very easily.
  • It is very easier to build an integration test database
  • Full versioning of database. You can migrate it into any version at any point in time.
  • This approach can be used for any new project or old project with existing databases.
  • Give you the full control over the database.

Leave a comment