⚙️

Backend Technologies · .NET

Entity Framework Core — Free Learning Resources

Free, printable resources for Entity Framework Core — practice problems, quick-reference cheatsheet, and an interview prep sheet. No sign-up required.

📝Practice Worksheet

Entity Framework CorePractice Worksheet

Structured exercises and problems to build hands-on Entity Framework Core skills. Work through key concepts step by step.

📋Cheatsheet

Entity Framework CoreCheatsheet

One-page quick-reference for Entity Framework Core — key syntax, commands, patterns, and best practices at a glance.

🎯Interview Sheet

Entity Framework CoreInterview Sheet

Top Entity Framework Core interview questions with concise answers. Get ready for any technical round with this focused prep sheet.

About Entity Framework Core

Entity Framework Core is Microsoft's modern, open-source ORM for .NET. It enables .NET developers to work with databases using .NET objects, eliminating most data-access code. EF Core supports Code-First migrations, LINQ queries, and multiple database providers (SQL Server, PostgreSQL, SQLite, MySQL).

Entity Framework CoreCheat Sheet — What's Covered

  • DbContext setup, entity configuration, and the Fluent API
  • Code-First migrations — Add-Migration, Update-Database, and rollbacks
  • LINQ queries — filtering, projection, joins, and eager loading
  • Change tracking — how EF Core detects and persists changes
  • Performance — AsNoTracking, compiled queries, and raw SQL when needed

Frequently Asked Questions — Entity Framework Core

How does EF Core's change tracking work?

When you load entities via DbContext, EF Core tracks their original values. Calling SaveChanges() detects what changed, generates the appropriate INSERT/UPDATE/DELETE SQL, and executes it in a transaction. Use AsNoTracking() for read-only queries to skip tracking overhead.

What is the difference between eager and lazy loading in EF Core?

Eager loading fetches related data in the same query using .Include(p => p.Orders). Lazy loading fetches related data on first access (requires virtual navigation properties and the Microsoft.EntityFrameworkCore.Proxies package). Eager loading is safer and avoids N+1 queries.

How do EF Core migrations work?

Run dotnet ef migrations add MigrationName to generate a migration file from model changes. Run dotnet ef database update to apply it. EF Core tracks applied migrations in __EFMigrationsHistory. Roll back with dotnet ef database update PreviousMigrationName.

When should you use raw SQL in EF Core?

Use FromSqlRaw() for complex queries that EF Core can't generate efficiently (CTEs, window functions, stored procedures). Use ExecuteSqlRaw() for non-query operations. Always parameterize values — never concatenate user input. EF Core's LINQ covers 90% of cases.

How do you configure entity relationships in EF Core?

Use data annotations (@ForeignKey, @Required) on entity properties, or the Fluent API in OnModelCreating: modelBuilder.Entity<Post>().HasOne(p => p.Blog).WithMany(b => b.Posts).HasForeignKey(p => p.BlogId). The Fluent API is more expressive for complex configurations.

Who Is This For?

C# and .NET developers who want a productive ORM that eliminates boilerplate SQL while retaining full control over queries and schema.

Resource Details

FormatPDF, Printable
Cheat Sheet1 page, landscape
Interview Sheet10 questions + answer lines
Practice Sheet10 Q&A pairs with answers
PriceFree
Back to Entity Framework Core