Coding

Published on January 8th, 2017 | by Guest

0

Latest Entity framework Core 1.1 for ASP.NET

So, the latest version of Entity framework core – Core 1.1 Preview 1 is out! Asp.net development services provider explains how to upgrade to Preview 1 in this article. The experts also explain the new features of Preview 1 in this post. Read them thoroughly and find what they have to share.

The Entity Framework Core is extensible, cross-platform and lightweight version of the Entity framework. The latest version of Entity Framework core is Core 1.1 Preview 1.

Upgrade To Preview 1 Version

In case a programmer is using database providers that are shipped by the team of Entity framework, then simply upgrade the provider package.

PM>Update-Package Microsoft.EntityFrameworkCore.SqlServer  -Pre

In case a database provider from third party is used, then first check if it has an update for EF 1.1 Preview 1 version. In case it is there, then simply upgrade to newer version, else update only the dependent relational components of Entity Framework Core.  Majority of features in Preview 1 do not need to make any changes in the database provider. It has been ensured through testing that the database providers depending on 1.0 will also work with 1.1Preview 1.

PM>Update-Package Microsoft.EntityFrameworkCore.Relational  -Pre

Upgrade Tooling Packages

In case a tooling Package is used, make sure that it is also upgraded. In case Asp.Net Core is used, then make an update in the tools section of the project.json file for using the Microsoft.EntityFrameworkCore.Tools.Dotnet package.

PM>Update-Package Microsoft.EntityFrameworkCore.Tools -Pre

Also, it is required to separate the tools of dotnet in a separate package as shown below:

"tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
},

New Features in 1.1 preview 1

 

  • Improvement in LINQ translation:

 

There has been great progress in the Linq provider of Entity Framework Core in Preview1. It allows more queries to be executed successfully and more logic is evaluated in database as compared to memory.

 

  • DBSet.Find:

 

DBSet.Find (…) is available in EF6.x. This API is most common request in Entity Framework Core. It enables programmers to create a query for an entity on the basis of the value of primary key.  In case, the entity already exists in the context, then its value is returned without any need to query the database.

 

  • Mapping To Fields

 

The HasField (…) method of API allows programmers to do configuration of a backing field for property. It is usually done in cases where there is no setter for a property.

EF will by default use a field while creating objects of entity in a query or in case when property cannot be used. It can be changed with the UsePropertyAccessMode (…) API.

Also it is possible to create a property in model which does not have appropriate property in entity class. It is not similar to the Shadow Properties which stores the data in change tracker.

 

  • Connection Resiliency:

 

The connection resiliency is used to retrieve the database commands that failed. An execution strategy is included in this release that is tailored particularly to the SQL server. It is included in SQL Server Provider. It has knowledge of exception types that could be retired contains defaults for maximum number of retires.

 

  • SQL Support for Memory Optimized Tables:

 

One of the main features of SQL Server is memory optimized tables. It is possible to specify that the entity is mapped to a table that is memory optimized. In case an EF Core is used for creating and maintaining a database on the basis of model, an optimized table will be made for the entities.

 

  • Simple Service Replacement:

 

It is possible to easily replace the internal services used by the Entity Framework in Entity Framework Core 1.1. It can be done with a ReplaceService method that is used while performing the context configuration.

 

  • Additional API’s of Entity Entry:

 

The remaining API’s of Entity Entry have been added in Entity Framework EF6.x. It includes the methods such as GetDatabaseValues (), GetModifiedProperties (), Reload () etc. To access these APIs, DBContext.Entry () method is used.

Entity framework 1.1 with Xamarin Portable Library

There is no support yet to run Entity Framework Core 1.1 on Xamarin Portable Library. However, since Xamarin has support for nonstandard, it works in the basic scenarios. Currently the developers are investigating about the issues and may move to supported scenarios if very few issues are found.

Entity Framework Support for GraphDiff Library:

Entity framework Core has made some improvement to implement features similar to GraphDiff library. EF Core is smarter enough to set state of the available related entities.  There is an API DBContext.ChangeTracker.TrackGraph (…) that allows the computation of each available entity’s state. Solutions such as GraphDiff are pretty opinionated regarding the calculation of state. Hence they are great extensions but they are not much general purpose for its existence in the Entity Framework Core.

The main goal of the Entity Framework Core is cross platform. Core is future of the .Net development. However, it lacks support for the transaction scope. It is easy to subscribe an ambient transaction in case where SQL is the provider. There is already the detection of ambient transaction. Transaction Scope is on the top of the list to be added to the .Net Core.

Some ground is built for the lazy loading in the release. However, the main requirement was to implement the explicit loading. Lazy loading is layered on the top in the upcoming release.

Group by translation is not implemented yet in the release. A GroupBy is not always implied by the LINQ Groupby. A GroupBy is translated whenever there is a Linq GroupBy is used with the aggregating function for select expression.  In case, the groups have not been aggregated, then al results will come from the database and then will be placed in the group memory.

So, you now know the features of latest entity framework Core 1.1. If you have something to ask from ASP.NET development services provider, make comments below.

Tags: , , , ,


About the Author

Contribution of guest authors towards Techno FAQ blog



Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top ↑