BT

Entity Framework Core 2.1 Release Adds Improved SQL Query Generation

| by Jeff Martin Follow 16 Followers on Jun 04, 2018. Estimated reading time: 1 minute |

Microsoft has released Entity Framework Core 2.1, bringing with it many features existing EF developers have long waited for.  EF Core 2.1 adds support for SQL GROUP BY, support for Lazy Loading, and data seeding, among others.

The first big addition to EF Core 2.1 is that the use of GroupBy LINQ operator will now be translated into proper SQL using the GROUP BY clause.  The lack of this support was considered a big omission in EF Core 2.0.  Similarly, support for Lazy Loading has made it into EF Core 2.1.  To support the addition of Lazy Loading, entities that take parameters in their constructors can now be created.  Once defined, EF Core can call this constructor when creating an instance of the entity.

EF Core now supports the ability to programmatically populate a database with initial data. In a departure from EF6, "seeding data is associated with an entity type as part of the model configuration".  But there are some open items from EF Core 2.0 that remain out of 2.1.  For example, Table Per Type remains an open issue on the GitHub project page.

The packaging of EF has been simplified in this release, with the command line tools now part of the .NET Core SDK.  They can be accessed through dotnet ef and the previous reference to them (DotNetCliToolReference) in a project is not required.  However, these commands only support EF Core 2.0/2.1, so care must be taken if it is necessary to support EF Core 1.0/1.1.

EF Core 2.1 is available now through the installation of the .NET Core 2.1 SDK.  Since EF Core 2.1 conforms to .NET Standard 2.0, it will run on both .NET Core 2.0 and .NET Framework 4.6.1 or later.

If you are upgrading from a previous build, it is important to note that the packages providing support for your database provider should be upgraded.  Attempting to use a database provider designed for EF Core 2.0 will cause problems in EF Core 2.1, and not all of them will be immediately noticeable so to save frustration it is best to update.  Microsoft suggests directly updating via dotnet add package to ensure the proper version is loaded.

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
Community comments

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

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