Getting started with EF Core

EF Core Approaches

EF Core Approaches

Migrations

This approach used to be called as code first approach in legacy entity framework. In this approach the model drives all the changes to the database, this is more of developer centric approach where the code dictates terms! This is the suggested approach in all the projects except where the developers have no exclusive control on the database are the team is using the shared database with other teams.

Scaffolding

In this approach we reverse engineer the models from an existing database. All the changes are made in the database and we need to constantly keep scaffolding the changes on to the code. In legacy entity framework this was called data first approach. We use this when the database is shared across different teams, and we cannot have the code dictate terms on the database.

It is recommended to use migrations wherever possible since the framework can keep track of changes required for the database, reducing manual tracking and hence reducing errors which happen because of data impedance mismatch.

Last updated