Back to Entityframework

Compare EF6 and EF Core

entity-framework/efcore-and-ef6/index.md

latest12.1 KB
Original Source

Compare EF Core & EF6

EF Core

Entity Framework Core (EF Core) is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.

EF Core works with SQL Server/Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL, and many more databases through a database provider plugin model.

EF6

Entity Framework 6 (EF6) is an object-relational mapper designed for .NET Framework but with support for .NET Core. EF6 is a stable, supported product, but is no longer being actively developed.

Feature comparison

EF Core offers new features that won't be implemented in EF6. However, not all EF6 features are currently implemented in EF Core.

The following tables compare the features available in EF Core and EF6. This is a high-level comparison and doesn't list every feature or explain differences between the same feature in different EF versions.

The EF Core column indicates the product version in which the feature first appeared.

Creating a model

FeatureEF6.4EF Core
Basic class mappingYes1.0
Constructors with parameters2.1
Property value conversions2.1
Mapped types with no keys2.1
ConventionsYes1.0
Custom conventionsYes7.0
Data annotationsYes1.0
Fluent APIYes1.0
Inheritance: Table per hierarchy (TPH)Yes1.0
Inheritance: Table per type (TPT)Yes5.0
Inheritance: Table per concrete class (TPC)Yes7.0
Shadow state properties1.0
Alternate keys1.0
Many-to-many navigationsYes5.0
Many-to-many without join entityYes5.0
Key generation: DatabaseYes1.0
Key generation: Client1.0
Complex/owned typesYes2.0
Spatial dataYes2.2
Model format: CodeYes1.0
Create model from database: Command lineYes1.0
Update model from databasePartialOn the backlog (#831)
Global query filters2.0
Table splittingYes2.0
Entity splittingYes7.0
Database scalar function mappingPoor2.0
Database table valued function mappingPoor5.0
Field mapping1.1
Nullable reference types (C# 8.0)3.0
Graphical visualization of modelYesNo support planned <sup>(1)</sup>
Graphical model editorYesNo support planned <sup>(1)</sup>
Model format: EDMX (XML)YesNo support planned <sup>(1)</sup>
Create model from database: VS wizardYesNo support planned <sup>(1)</sup>

Querying data

FeatureEF6.4EF Core
LINQ queriesYes1.0
Readable generated SQLPoor1.0
GroupBy translationYes2.1
Loading related data: EagerYes1.0
Loading related data: Eager loading for derived types2.1
Loading related data: LazyYes2.1
Loading related data: ExplicitYes1.1
Raw SQL queries: Entity typesYes1.0
Raw SQL queries: Keyless entity typesYes2.1
Raw SQL queries: Composing with LINQ1.0
Explicitly compiled queriesPoor2.0
await foreach (C# 8.0)3.0
Text-based query language (Entity SQL)YesNo support planned <sup>(1)</sup>

Saving data

FeatureEF6.4EF Core
Change tracking: SnapshotYes1.0
Change tracking: NotificationYes1.0
Change tracking: ProxiesYes5.0
Accessing tracked stateYes1.0
Optimistic concurrencyYes1.0
TransactionsYes1.0
Batching of statements1.0
Stored procedure mappingYes7.0
Disconnected graph low-level APIsPoor1.0
Disconnected graph End-to-end1.0 (partial; #5536)

Other features

FeatureEF6.4EF Core
MigrationsYes1.0
Database creation/deletion APIsYes1.0
Seed dataYes2.1
Connection resiliencyYes1.1
InterceptorsYes3.0
EventsYes3.0 (partial; #626)
Simple Logging (Database.Log)Yes5.0
DbContext pooling2.0

Database providers <sup>(2)</sup>

FeatureEF6.4EF Core
SQL ServerYes1.0
MySQLYes1.0
PostgreSQLYes1.0
OracleYes1.0
SQLiteYes1.0
SQL Server CompactYes1.0 <sup>(3)</sup>
DB2Yes1.0
FirebirdYes2.0
Jet (Microsoft Access)2.0 <sup>(3)</sup>
Azure Cosmos DB3.0
In-memory (for testing)1.0

<sup>1</sup> Some EF6 features will not be implemented in EF Core. These features either depend on EF6's underlying Entity Data Model (EDM) and/or are complex features with relatively low return on investment. We always welcome feedback, but while EF Core enables many things not possible in EF6, it is conversely not feasible for EF Core to support all the features of EF6.

<sup>2</sup> EF Core database providers implemented by third-parties may be delayed in updating to new major versions of EF Core. See Database Providers for more information.

<sup>3</sup> The SQL Server Compact and Jet providers only work on .NET Framework (not on .NET Core).

Supported platforms

EF Core 3.1 runs on .NET Core and .NET Framework, through the use of .NET Standard 2.0. However, EF Core 5.0 does not run on .NET Framework. See Platforms for more details.

EF6.4 runs on .NET Core and .NET Framework, through multi-targeting.

Guidance for new applications

Use EF Core on .NET Core for all new applications unless the app needs something that is only supported on .NET Framework.

Guidance for existing EF6 applications

EF Core is not a drop-in replacement for EF6. Moving from EF6 to EF Core will likely require changes to your application.

When moving an EF6 app to .NET Core:

  • Keep using EF6 if the data access code is stable and not likely to evolve or need new features.
  • Port to EF Core if the data access code is evolving or if the app needs new features only available in EF Core.
  • Porting to EF Core is also often done for performance. However, not all scenarios are faster, so do some profiling first.

See Porting from EF6 to EF Core for more information.