What is Entity Framework Core?
Quick Answer
Entity Framework Core is Microsoft's lightweight, cross-platform object-relational mapper (ORM) for .NET. It lets you work with a database using C# classes and LINQ instead of hand-written SQL: DbContext represents a session with the database, DbSet<T> represents a table, and EF Core translates your LINQ queries to SQL, tracks changes and generates INSERT/UPDATE/DELETE on SaveChanges().
EF Core is Microsoft's ORM — it maps database tables to C# classes so I can query with LINQ and save with SaveChanges instead of writing SQL and mapping result sets by hand. DbContext is the session and the unit of work, DbSet is a table, and EF translates my LINQ to SQL and works out the insert, update and delete statements from what changed. It's a rewrite of the old EF6 — cross-platform, faster, more providers, better query translation. The thing I always add is that EF Core doesn't remove the need to understand SQL — I still check the generated queries and watch for N+1 and tracking overhead.
An ORM maps rows to objects so you don't write repetitive data-access code. EF Core's building blocks:
DbContext— a unit of work and identity map for one logical operation (usually one request). Holds the change tracker.DbSet<T>— a queryable, addable collection mapped to a table.- Model / configuration — conventions, data annotations, or the Fluent API in
OnModelCreatingdefine keys, relationships, column types. - Provider — SQL Server, PostgreSQL, SQLite, etc. translate the query.
- Migrations — versioned schema changes generated from model changes.
EF Core vs EF6: EF Core is a rewrite — cross-platform, faster, supports more databases, better LINQ translation and batching — but it dropped some EF6 features (lazy loading needed a package initially, no EDMX designer, some mapping differences). New projects use EF Core.
Interviewers want to know you understand EF Core is a convenience layer over SQL, not a replacement for understanding SQL — you still need to watch generated queries, N+1 problems and tracking overhead.
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
public DbSet<Customer> Customers => Set<Customer>();
public DbSet<Order> Orders => Set<Order>();
}
// query -> SELECT ... WHERE ... ORDER BY ...
var recent = await _db.Orders
.Where(o => o.CustomerId == id)
.OrderByDescending(o => o.OrderDate)
.Take(10)
.ToListAsync();
- Query and persist with C# and LINQ instead of hand-written SQL and mapping code
- Change tracking generates the right INSERT/UPDATE/DELETE automatically
- Migrations keep the schema in version control alongside the model
- Provider model — swap SQL Server for PostgreSQL or SQLite with little code change
- Strong typing catches column and relationship mistakes at compile time