BT

Entity Framework 7: New Platforms and New Data Stores

| by Jonathan Allen Follow 576 Followers on Apr 30, 2015. Estimated reading time: 2 minutes |

Entity Framework was created solely for working with relational data on the full version of .NET. In EF 7, neither of those statements is true.

The platform goal for Entity Framework 7 includes

  • .NET Full Framework
  • ASP.NET 5
  • Windows 10 UAP
  • Mac
  • Linux

On the provider side, EF 7

  • Relational Providers: SQL Server, SQLite, Postgres
  • Azure Table Storage
  • Redis
  • In Memory Provider (for testing)

The Top-level experience is the same as EF 6, you will still be working with DbContext, DbSet, etc. Internally the core has been rewritten. This means the metadata, change tracking, query pipeline, etc. are all different, but for most applications the developer won’t notice.

The core is being changed for a number of reasons. One reason is that current architecture is very difficult to work with. Even basic things like plugging in a logging framework is far more difficult that necessary. By rewriting the core, confusing APIs and behaviors can finally be removed.

EF is well known for being memory hungry and slow. A major emphasis for the rewrite is to address these concerns. This is important across the board, from small mobile devices with limited battery life to massive cloud severs where you pay for CPU utilization.

Logging

Logging in Entity Framework is based on the ILogger interface from the Microsoft.Owin.Logging namespace. Microsoft’s hope is that this will become the standard interface that all .NET logging frameworks support.

SQL Generation Improvements

Insert and update operations are slightly better in EF 7. Say, for example, you want to apply a discount to four products in a table. When using EF 6, this would require 1+N round-trips to the database: one to load the data and one for each row. In EF 7, save operations are batched so that you only need two round-trips to the database.

This is still slower than the one round trip that you would get when using native SQL, but it also works for non-relational databases.

Mixing SQL and LINQ

EF 7 supports mixing FromSQL with LINQ expressions. This allows you to access things that EF cannot normally work with such as Table Value Functions or index-hinted tables.

context.FromSql<Customer>("SELECT * FROM Customer (WITH (IX_Index)").OrderBy(c => c.Name)

This will generate the correct SQL to perform the order by, where, etc. in the database.

EF and Mobile Devices

As mentioned above, one of the goals of EF 7 is to not be limited to just desktop applications. One of the use cases for this is offline mobile devices. The idea is that you should be able to use the same code on your mobile device to locally cache and manipulate data that you would use on your server.

For more information on Entity Framework 7, watch the Channel 9 video Entity Framework 7: Data for Web, Phone, Store, and Desktop.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

A Logger interface by li min feng

hehe, will microsoft will kill log4net, NLog?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT