Stage 2 · Lesson 9 of 10
Entity Framework Core and migrations
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
- CoursePaidGrokking Relational Database Design and Modeling
Design Gurus · Intermediate · $98 one-time
The modelling and normalisation decisions that stay with a codebase for years
- CourseFreeCS50's Introduction to Databases with SQL
Harvard University · Beginner
Free course from querying through schema design, indexes, transactions and scaling
Practise
Also worth your time
- Database Indexing Explained: B-Tree, Hash, Bitmap, R-Tree, and When to Use Each (opens in a new tab)Read
B-tree and composite indexes, plus the leftmost-prefix rule that trips people up
What sits under your queries: storage engines, transactions and isolation levels