Comparing Entity Framework Core and Entity Framework 6

Tram Ho

1. Introduction to Entity Framework Core

Entity Framework Core (EF Core) is a new object-database mapping framework for .NET. It supports LINQ queries, track changes, updates and structural changes. EF Core works with SQL Server / SQL Azure, SQLite, Azure Cosmos DB, MySQL, PostgreSQL, and many other databases through the database plugin model.

2. Introduction to Entity Framework 6

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

3. Compare Entity Framework Core and Entity Framework 6

EF Core offers new features that will not be implemented in EF6. However, not all EF6 features are currently implemented in the EF Core. The following tables compare the features available in EF Core and EF6. This is a high-level comparison and does not list every feature or explain the differences between the same feature in different EF versions.

Create model

FeatureEF 6.4EF Core
Basic class mappingYes1.0
Basic class mappingYes1.0
Constructors with parameters2.1
Property value conversions2.1
Mapped types with no keys2.1
ConventionsYes1.0
Custom conventionsYes1.0 (partial)
Data annotationsYes1.0
Fluent APIYes1.0
Inheritance: Table per hierarchy (TPH)Yes1.0
Inheritance: Table per type (TPT)YesPlanned for 5.0
Inheritance: Table per concrete class (TPC)YesStretch for 5.0 (1)
Shadow state properties1.0
Alternate keys1.0
Many-to-many navigationsYesPlanned for 5.0
Many-to-many without join entityYesOn the backlog
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
Global query filters2.0
Table splittingYes
Entity splittingYesStretch for 5.0 (# 620) (1)
Database scalar function mappingPoor2.0
Field mapping1.1
Nullable reference types (C # 8.0)3.0
Graphical visualization of modelYesNo support planned (2)
Graphical model editorYesNo support planned (2)
Model format: EDMX (XML)YesNo support planned (2)
Create model from database: VS wizardYesNo support planned (2)

Data access

FeatureEF 6.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 (2)

Save the data

FeatureEF 6.4EF Core
Change tracking: SnapshotYes1.0
Change tracking: NotificationYes1.0
Change tracking: ProxiesYesMerged for 5.0
Accessing tracked stateYes1.0
Optimistic concurrencyYes1.0
TransactionsYes1.0
Batching of statements1.0
Stored procedure mappingYesOn the backlog
Disconnected graph low-level APIsPoor1.0
Disconnected graph End-to-end1.0

Other function

FeatureEF 6.4EF Core
MigrationsYes1.0
Database creation / deletion APIsYes1.0
Seed dataYes2.1
Connection resiliencyYes1.1
InterceptorsYes3.0
EventsYes3.0 (partial)
Simple Logging (Database.Log)YesMerged for 5.0
DbContext pooling2.0

Databases are supported

FeatureEF 6.4EF Core
SQL ServerYes1.0
MySQLYes1.0
PostgreSQLYes1.0
OracleYes1.0
SQLiteYes1.0
SQL Server CompactYes1.0 (4)
DB2Yes1.0
FirebirdYes2.0
Jet (Microsoft Access)2.0 (4)
Azure Cosmos DB3.0
In-memory (for testing)1.0

Note:
(1): Not yet likely to appear for a given release. However, it will appear soon in the future.
(2): Some features of EF6 will not be implemented in EF Core.
(3): Third-party-deployed EF Core database may be delayed in updating to new versions of EF Core.
(4): SQL Server Compact and Jet only work on .NET Framework (not on .NET Core).

4. Supporting platform

EF Core 3.1 runs on .NET Core and .NET Framework, through the use of .NET Standard 2.0. However, EF Core 5.0 will not run on the .NET Framework. EF6.4 runs on .NET Core and .NET Framework through multi-targeting.

5. Conclusion

Above are some comparisons between EF Core and EF6. Each framework has advantages and disadvantages. In the future, the EF Core will gradually have all the features of the EF6 but at the present time the EF6 will probably operate more stably. So you can rely on your own comparisons and needs to choose the right framework for your current project and hope your article can partially support you to make a decision.

Share the news now

Source : Viblo