Cover of The Entity Framework Core Handbook by Rachid Dahir
Entity Framework Core 10 In progress

The Entity Framework Core Handbook

Modelling, migrations, querying and tuning on EF Core 10

15 chapters 5 parts 5 appendices 15 exercise-solution projects

A practical handbook for C# developers who use EF Core in real applications — modelling a domain, evolving a schema safely, and writing queries that generate good SQL.

Get it on Leanpub
Pay what you want on Leanpub

PDF. Read a free sample on Leanpub before you buy.

This book is still being revised. Buying it now gets you the current draft plus every revision until it is finished, at no extra cost — that is how Leanpub in-progress books work.

About this book

This is a practical handbook for C# developers using Entity Framework Core 10 in real applications. It works through the four things that actually take up your day: modelling a domain, evolving a schema safely with migrations, writing queries that generate good SQL, and diagnosing the ones that don’t.

It covers the modern EF Core 10 surface rather than the 2016 one — data annotations and the Fluent API, owned types and advanced entity configuration, JSON columns, vector search for AI workloads, interceptors, logging and diagnostics, performance optimization, and where EF Core belongs in an application’s architecture. The running example is PawCare, a veterinary-clinic application that grows alongside the chapters instead of restarting on every page.

The companion code is pinned so it stays reproducible: EF Core 10.0.10 and Microsoft.Data.SqlClient 6.1.x. Nothing needs Docker — anything that requires a connection string uses LocalDB, so the exercise solutions run on a plain Windows development machine.

What you’ll learn

01

Set up a project and a DbContext, and go from plain C# classes to a working database schema.

02

Configure the model with data annotations, the Fluent API, and advanced entity configuration when the domain needs it.

03

Evolve a live schema safely with migrations.

04

Query and save data with EF Core, and understand the SQL each pattern produces.

05

Work with JSON columns and add vector search for AI workloads.

06

Diagnose with logging, shape the pipeline with interceptors, tune performance, and place EF Core in an application architecture.

Built on

.NET 10 LTS C# 14 EF Core 10.0.10 Microsoft.Data.SqlClient 6.1 SQL Server / LocalDB Vector search Interceptors BenchmarkDotNet

Table of contents

Five parts, fifteen chapters, five appendices.

Part I — Foundations

  1. Introduction to Entity Framework Core
  2. Building the Foundation: Project Setup and DbContext
  3. From Code to Database: The First Schema

Part II — Modelling the Domain

  1. Configuring the Model with Data Annotations
  2. Advanced Model Configuration with the Fluent API
  3. Managing Database Schema with Migrations
  4. Advanced Entity Configuration

Part III — Working with Data

  1. Querying Data with EF Core
  2. Saving Data with EF Core
  3. Working with JSON Data
  4. Vector Search and AI Workloads

Part IV — Diagnostics and Performance

  1. Logging and Diagnostics
  2. Unlocking the Pipeline with Interceptors
  3. Performance Optimization

Part V — Architecture

  1. EF Core in Application Architecture

Back matter

  • Five appendices, A to E
  • Index

Inside the book

Code in the text is not pseudocode. Every listing belongs to a chapter demo or to the PawCare application, and the SQL it generates is shown alongside it.

// PawCare: a read-only projection, so the change tracker stays out of it.
public sealed class PawCareContext(DbContextOptions<PawCareContext> options)
    : DbContext(options)
{
    public DbSet<Patient>     Patients     => Set<Patient>();
    public DbSet<Appointment> Appointments => Set<Appointment>();
}

var upcoming = await db.Appointments
    .AsNoTracking()
    .Where(a => a.StartsAt >= DateTime.UtcNow)
    .OrderBy(a => a.StartsAt)
    .Select(a => new AppointmentSummary(a.Id, a.Patient.Name, a.StartsAt))
    .ToListAsync(ct);
Read the free sample on Leanpub

Companion code

Fourteen chapter demos plus the PawCare veterinary-clinic application, with a project behind every exercise solution. Delivered with the book rather than as a public repository.

Chapter demos
14
Application
PawCare
Exercise solutions
15
Database
LocalDB

No Docker required. Packages are pinned to EF Core 10.0.10 and Microsoft.Data.SqlClient 6.1.x.

Who this is for

  • C# developers using EF Core in real applications, not just in tutorials.
  • Developers who write LINQ every day and want to know what SQL it produces.
  • Teams evolving a live schema who need migrations to be boring and predictable.
  • Anyone adding JSON documents or vector search to an existing relational model.

What it is not

  • An introduction to C#. You should be able to read and write it fluently.
  • A SQL primer. Basic relational concepts are assumed.
  • A reference for every database provider. The samples target SQL Server and LocalDB.

Frequently asked

EF Core 10, on .NET 10 LTS with C# 14. The companion code pins EF Core 10.0.10 and Microsoft.Data.SqlClient 6.1.x so the samples build the same way on every machine.

The samples target SQL Server through LocalDB, so there is no separate server to install or administer. The modelling, migrations and querying material is largely provider-agnostic; the chapters on JSON data and vector search lean on SQL Server features and say so where they do.

No. The exercise solutions run as they are, and anything that needs a connection string uses LocalDB.

Yes. The book starts from project setup, a DbContext, and a first schema rather than assuming EF Core habits, so the concepts you already know map across. It teaches the EF Core 10 API on its own terms rather than as a diff against EF6.

Yes. Chapter 14 is devoted to performance optimization, and Chapter 12 covers the logging and diagnostics you need to find the slow query before you tune it.

The Entity Framework Core Handbook

Fifteen chapters across five parts, and one veterinary-clinic application that grows with them.

Get it on Leanpub

Not ready to buy? Start with the free book.