Entity Framework Core
Work with a database through C# objects while staying aware of the SQL underneath, including the performance traps that catch most teams.
Prerequisites
- C# fundamentals
- Basic SQL: SELECT, JOIN, WHERE
Technologies
About this course
EF Core removes a lot of repetitive data-access code. It also makes it easy to write something that looks fine and performs badly, because the generated SQL is out of sight unless you go looking.
This course teaches both halves. You will learn the mapping, relationships, migrations and query APIs, and you will also learn to inspect what EF Core actually sent to the database, so performance work is based on evidence.
The N+1 query problem gets a full treatment, since it is the single most common EF Core performance bug and it is almost invisible until a list grows.
Course roadmap
All 17 lessons are written and available.
- 01What Is an ORM?Explain what an ORM does for you, and what it deliberately hides.13 min
- 02EF Core ArchitectureDescribe how EF Core turns a LINQ query into SQL and results into objects.16 min
- 03DbContextConfigure a context and understand its lifetime and responsibilities.18 min
- 04Your First Query and SaveRead and write data, and see the SQL that was generated.18 min
Module 02
Modelling and Migrations
Describe your data as C# types, and evolve the database alongside your code.
- 01Entities and ConfigurationMap classes to tables using conventions and explicit configuration.19 min
- 02RelationshipsModel one-to-many, many-to-many and one-to-one relationships correctly.22 min
- 03MigrationsEvolve a schema safely, with changes reviewable in version control.20 min
- 04Code First and Database FirstChoose an approach based on who owns the schema.16 min
Module 03
Querying and Saving
Read data efficiently, understand change tracking, and save work atomically.
- 01Eager, Lazy and Explicit LoadingControl when related data is fetched and at what cost.16 min
- 02ProjectionSelect only the columns you need instead of loading whole entities.14 min
- 03Change TrackingExplain what tracking does and when to disable it.15 min
- 04TransactionsGroup related changes so they succeed or fail together.14 min
- 05Concurrency ConflictsDetect and resolve two users editing the same record.18 min
Module 04
Performance and Escape Hatches
Find out what SQL is actually running, fix the common traps, and know when to write SQL yourself.
- 01The N+1 Query ProblemRecognise, reproduce and fix the most common EF Core performance bug.20 min
- 02IndexesAdd indexes that support your real queries.16 min
- 03Raw SQL and Stored ProceduresDrop to SQL when the ORM is the wrong tool, without losing safety.16 min
- 04Query OptimisationDiagnose a slow query from the generated SQL and its plan.18 min
Projects for this course
Employee Management API
A production-shaped web API: validated, paged, documented, secured, backed by a real database and covered by tests.
Inventory Management System
A data-focused build: stock levels, movements, concurrency and reporting that must stay correct under simultaneous use.
On completion
What you should take away
- An ORM is a convenience layer, and you remain responsible for the queries it generates
- Relationships and loading strategy determine most of your query performance
- Projection is usually better than loading entities you do not need
- Migrations belong in version control alongside the code that depends on them
Recommended next course
Automated Testing
Write tests that let you change code with confidence: unit, integration and API tests, test doubles, and what coverage really tells you.
Continue to TestingHave a project worth talking through?
Tell us what you're building or what's slowing your current system down. We'll give you a direct read on scope and approach.