wasAsked.

What is the difference between Entity Framework 6 and Entity Framework Core?

Frequently Asked (All Companies) · Role not specified · technical

Published

Year not specified · Entity Framework Core, .NET

Community answers

Posted by wasAsked editorial collection

Entity Framework 6 (EF6) is the mature ORM for .NET Framework. Entity Framework Core (EF Core) is a lightweight, cross-platform rewrite designed for modern .NET. EF Core is where all new development happens; EF6 is in maintenance mode. Platform - EF6 was built for .NET Framework. EF 6.3+ can also run on .NET Core and modern .NET (Windows-focused tooling), mainly to help migrations of existing applications. - EF Core runs on modern .NET across Windows, Linux and macOS, in containers and the cloud. Development status - EF6 receives only critical fixes; no new features. - EF Core ships a new major version every November with .NET (EF Core 8, 9, 10...), with major performance and feature improvements. Performance - EF Core is significantly faster in many scenarios thanks to a redesigned query pipeline, compiled models, DbContext pooling, batching of SaveChanges statements, and efficient bulk operations (ExecuteUpdate and ExecuteDelete). Database providers - EF6: mainly SQL Server, plus a few third-party providers. - EF Core: SQL Server, Azure SQL, PostgreSQL (Npgsql), MySQL, SQLite, Oracle, Cosmos DB, an in-memory provider for simple testing, and more. Modelling approaches - EF6 supports Code First, Database First and Model First with the EDMX visual designer. - EF Core supports Code First and reverse engineering (scaffolding) from an existing database; there is no EDMX designer (tools such as EF Core Power Tools fill the gap). Feature differences EF Core added or improved: - Global query filters (soft delete, multi-tenancy), with named filters in EF Core 10. - Shadow properties and backing fields. - Alternate keys and better value conversions. - Owned types and complex types (value objects), JSON columns. - Better LINQ translation and split queries (AsSplitQuery). - Bulk updates and deletes without loading entities (ExecuteUpdateAsync, ExecuteDeleteAsync). - Interceptors and diagnostic events, compiled queries and compiled models. - Temporal table support, many-to-many relationships without explicit join entities (since EF Core 5), table-per-type and table-per-concrete-type inheritance. - Raw SQL queries for unmapped types (SqlQuery<T>), primitive collections. - Vector search support in recent versions. Behaviour differences - Lazy loading is opt-in in EF Core (requires proxies or ILazyLoader); EF6 enabled it by default. - Client evaluation: EF Core 3.0+ throws an exception for queries it cannot translate, instead of silently evaluating them in memory (EF6 and early EF Core could do this, which hid performance problems). - Configuration uses dependency injection (AddDbContext) and the options pattern instead of connection strings in app.config. Migrations - Both have Code First migrations, but the tooling differs (dotnet ef migrations add, migration bundles and idempotent scripts in EF Core). Migrating from EF6 to EF Core - Usually done when moving an application to modern .NET. - Steps: reverse engineer or port the model, rewrite Fluent API configuration, replace EDMX-based models, review queries that relied on client evaluation or lazy loading, test thoroughly and compare generated SQL. Interview summary: "EF6 is the legacy ORM for .NET Framework in maintenance mode. EF Core is the cross-platform, faster, actively developed successor with features like global query filters, bulk updates, many providers and better LINQ translation, but no EDMX designer. New projects should use EF Core."

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics