Wednesday, April 27, 2016

Introducing New Features in Entity Framework 6.1.0

Introduction
This article explains the latest version of Entity Framework, Entity Framework 6.1.0 features. The latest version of Entity Framework has some useful features that are given below and more useful features will be coming soon because this release is currently being worked on.
Check out the features below:
  • Handling of Transaction Commit Failures
  • Tooling Consolidation
  • Code First Annotations
  • IndexAttribute
  • Public Mapping API
I am describing some features in this article. So let's start.
Handling of Transaction Commit Failures
There is a new connection ability introduced in this version of Entity Framework. This feature has the functionality to encounter the short connection failure and get back automatically. Generally, there are two possible ways of exception raising during the transaction commit:
  • The transaction commit failed on the server
  • The transaction commit succeeded on the server but a connectivity issue prevented the success notification from reaching the client.
If the first exception occurs, then the user can execute the operation again. And if the second exception occurs then the user should not perform the execution again; the application could recover automatically. The new feature allows to Entity Framework  to double-click with the database it the transaction is done successfully. The following code snippet helps you to understand how we can use it:
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.SqlServer;

namespace MvcSample.Models
{
    public class MyDbConfiguration : DbConfiguration
    {
        public MyDbConfiguration()
        {
            SetTransactionHandler(SqlProviderServices.ProviderInvariantName, () => new CommitFailureHandler());
            SetExecutionStrategy(SqlProviderServices.ProviderInvariantName, () => new SqlAzureExecutionStrategy());
        }
    }
}
Tooling Consolidation
Using this feature we can select various contents to create or generate the model. We have a single entry point for creating the Entity Data Model.
Formerly the ADO.NET Entity Data Model did not have this facility.
Entity Data Model
We must install the Entity Framework Power Tools and use the Reverse Engineer Code First Tool for creating the Code First Models that targets an existing database. Have a look:
Generating Code First
Now the new wizard has the ability to support the creation of the Code First Models or they can select the Entity Framework Designer model also. They can also choose between a new and existing database.
Updgraded Entity Data Model Wizard
That's it.
Summary
This article explained the new features of the latest Entity Framework version 6.1.0. You can also check out the upgraded data model wizard to create the model in the latest framework. Thanks for reading.

No comments:

Post a Comment