Backend development

Stage 2 · Lesson 9 of 10

Entity Framework Core and migrations

Relational databases and SQL

Entity Framework Core () maps C# classes to database tables through a DbContext. It has one DbSet<Order> per table. Relationships are defined with navigation properties or the fluent .

You query with , and EF Core turns it into SQL. For changes, dotnet ef migrations add AddOrderStatus generates a from your model changes. dotnet ef database update applies it.

In production, generate an idempotent SQL script (safe to run twice) or a migration bundle, and run it as a deploy step. Read what each migration does, especially renames.

Common trapcalling ToList() too early. Everything after it runs in memory, so you end up filtering 2 million rows in C# instead of in the database.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

Also worth your time

Mark this stage as not done?