Entity Framework and EF Core

What is EF: EF is a Microsoft ORM, to perform CRUD operations in Databases. It was first introduced in year 2008.

Evolution of EF:

1

ef_version_history

What is EF Core: EF core is not upgrade to EF 6.x, it is a complete new port to EF, in simple word a new product. It is built from scratch EF with a goal of ‘EF everywhere’, which means EF will run on all platforms (.NET Framework, .NET Core and Xamarin).

EF Core in comparison to EF 6.x

  • Open Source: EF Core is open source project and is present on GitHub.

Link to GitHub: https://github.com/aspnet/EntityFramework

 

  • EF Core everywhere

EF 6.x works only on .NET Framework whereas EF core is designed to run on .NET Framework, .NET Core and Xamarin also.

ef6support
Entity Framework 6.X
efcore6support
Entity Framework Core
  • EF Core allows to use Non-Relational Databases also.

Following are examples providers of EF core

  1. Relational Providers: Sql server, Postgres, Sqlcompact etc.
  2. Non- Relational Providers: Azure Storage Table, Redis. In future, more Non -Relational providers will be added.

 

  • In-memory Testing: EF core is provided with InMemory provider which can be used in unit Testing by faking Db connection, without overhead of actual database operations.

 

  • Light weight & extensible core: EF core light weight and extensible also. The new architect of EF core makes it extensible.
extensiblecore
Entity Framework Core architecture
  1. Top level api is built over modular core
  2. Core Services are built as collection of services. IOC and DI is used while building these services.
  • Optimized for memory and CPU usage
  • Batching: During SaveChanges, EF 6 generates query for each update, insert or delete (except add range) while EF core uses batching.

Example: Following Code will generate 4 queries in EF 6 while one query in EF core. While EF core is smart enough to set batch size, user can also set it.

using (var context = new BlogContext())

{

context.Add<Blog>(new Blog { Id = 1, Name = “Blog1” });

context.Add<Blog>(new Blog { Id = 2, Name = “Blog4” });

context.Add<Blog>(new Blog { Id = 3, Name = “Blog4” });

context.Add<Blog>(new Blog { Id = 4, Name = “Blog4” });

context.SaveChanges();

}

  • Client eval in LINQ queries
  • Alternate keys.
  • EF core simplified metadata api
  • Same model, multiple platform: In EF Core, same model can be used for different platforms such as Sql Lite and Sql Server.
  • Same Model, multiple databases: In EF core, same model can be used for different databases.
  • Better caching: EF core has far better caching mechanism than EF 6.

 

Author: Rupesh

Hi! I'm Rupesh, a funophile and technophile. I'm an Application Developer, Solution Architect and IT-Consultant, and an author in the works. I am a Microsoft certified Professional and Solution Developer (MCP and MCSD).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s