EF7 is more powerful and has significant changes over Entity Framework 6.x. Rowan Miller recently announced new release of Entity Framework 7 beta 8 on his blog. Lot of features are still missing in current release, you can read EF 7 Roadmap on github.

Entity Framework 7 will give you familiar developer experience to previous versions of EF, the user can still work with DbContext, DbSet, etc. EF7 is much more lightweight than previous versions and is built from the ground up to work great in the cloud (using ASP.NET vNext) on devices (i.e. in universal Windows apps) as well as in traditional .NET scenarios.

This article outlines brief introduction to top 10 important features of Entity Framework 7.

Lightweight and extensible

Instead of use existing Entity Framework 6 APIs, Team decide to start developing from the scratch. You can use only that extensions which are useful to your project. The pattern and concept remain same to use Entity Framework. You can use DbContext/DbSet same way as you are currently using. The advantage of extensible is you can replace and extend it.

New Platforms

EF is most popular ORM that currently includes applications built with technologies such as WPF, WinForms and ASP.NET. After looking at future Microsoft has decided to support remaining platforms where .NET development is common. This includes Windows Store, Windows Phone and the Cloud Optimized .NET.

Based on people's higher request on EF uservoice "Improved SQL Generation", Diego Vega (Engineering Manager, Entity Framework) responded positively and start working on this feature. On next or may be final release they will include this feature. EF7 will generate much simpler SQL queries than EF6 for the most common scenarios.

Code first only

Finally Microsoft Team retired EDMX in Entity Framework 7. You can read Rowan Miller's article EF7 - What Does “Code First Only” really mean. If you still love edmx, you would love to read What about EDMX when EF7 arrives? written by Julie Lerman.

Batch Update

No longer need to use EF batch update utilities to perform batch operations because EF7 has inbuilt support for that. EF 7 no longer send individual command for every insert/update/delete statement. EF 7 will batch multiple statements in single round trip to the database.

Unique Constraints

EF 7 allows you to identify additional unique keys within your entities in addition to the primary key. You can then use these alternate keys as the target of foreign key relationships. A unique constraint is introduced for each alternate key in the model.

How it look like

By convention, the index and constraint that are introduced for an alternate key will be namedAK_<type name>_<property name>. For composite alternate keys <property name> becomes an underscore separated list of property names.

How to use it

You have to use fluent API because a unique constraint can not be configured using Data annotations.

class MyContext: DbContext

{

public DbSet < Employee > Employees

{

get;

set;

}

protectedoverridevoid OnModelCreating(ModelBuilder modelBuilder)

{

modelBuilder.Entity < Employee > ()

.HasAlternateKey(e => e.EmployeeCode)

.HasName("AlteranteKey_EmployeeCode");

}

}

class Employee

{

[Key]

publicint EmployeeId

{

get;

set;

}

publicstring Name

{

get;

set;

}

publicstring EmployeeCode

{

get;

set;

}

public DateTime DateOfBirth

{

get;

set;

}

}

In-Memory provider (for testing)

To test Entity Framework DB operations, we need to mock out DbContext which is not an easy task. In-memory store is useful to test data context without mock out it. In-memory store will behave same as a real data store. You can perform the same operations as In-memory providers..

Logging

Capture all interaction with the database using EF7 inbuilt Logging feature. EF7 logging feature is powered by Microsoft.Framework.Logging and Microsoft implemented ILogingFactory that may support all .NET platform (hope it will work). Take a look at very useful discussion already started on Stackoverflow

Shadow Properties

Shadow properties are properties that do not exist in entity class, but treated as part of it. The value and state of these properties is maintained purely in the Change Tracker. These properties can participate in all database operations, but should not be exposed via entity class to the rest of the application. Currently you can declare shadow properties using fluent API only.