Announcing Entity Framework Core 5.0 Preview 4

Jeremy Likness

Jeremy

Today we are excited to announce the fourth preview release of Entity Framework Core (EF Core) 5.0.

The fourth previews of .NET 5 and ASP.NET Core 5.0 are also available now. Be sure to check out the full release of Blazor WebAssembly 3.2.0!

Prerequisites

The previews of EF Core 5.0 require .NET Standard 2.1. This means:

  • EF Core 5.0 runs on .NET Core 3.1; it does not require .NET 5.
    • This may change in future previews depending on how the plan for .NET 5 evolves.
  • EF Core 5.0 runs on other platforms that support .NET Standard 2.1.
  • EF Core 5.0 will not run on .NET Standard 2.0 platforms, including .NET Framework.

How to get EF Core 5.0 previews

EF Core is distributed exclusively as a set of NuGet packages. For example, to add the SQL Server provider to your project, you can use the following command using the dotnet tool:

dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 5.0.0-preview.4.20220.10

The EF Core packages published today are:

We have also published the 5.0 preview 4 release of the Microsoft.Data.Sqlite.Core ADO.NET provider.

Installing dotnet ef

As with EF Core 3.0 and 3.1, the dotnet ef command-line tool is no longer included in the .NET Core SDK. Before you can execute EF Core migration or scaffolding commands, you’ll have to install this package as either a global or local tool.

dotnet-ef

To install the preview tool globally, first uninstall any existing version with:

dotnet tool uninstall --global dotnet-ef

Then install with:

dotnet tool install --global dotnet-ef --version 5.0.0-preview.4.20220.10

It’s possible to use this new version of dotnet ef with projects that use older versions of the EF Core runtime.


What’s new in EF Core 5 Preview 4

We maintain documentation covering new features introduced into each preview.

Some of the highlights from preview 4 are called out below. This preview also includes several bug fixes.

Configure database precision/scale in model

Precision and scale for a property can now be specified using the model builder. For example:

modelBuilder
    .Entity<Blog>()
    .Property(b => b.Numeric)
    .HasPrecision(16, 4);

Precision and scale can still be set via the full database type, such as “decimal(16,4)”.

Documentation is tracked by issue #527.

Specify SQL Server index fill factor

The fill factor can no be specified when creating an index on SQL Server. For example:

modelBuilder
    .Entity<Customer>()
    .HasIndex(e => e.Name)
    .HasFillFactor(90);

Documentation is tracked by issue #2378.


Daily builds

EF Core previews are aligned with .NET 5 previews. These previews tend to lag behind the latest work on EF Core. Consider using the daily builds instead to get the most up-to-date EF Core features and bug fixes.

As with the previews, the daily builds do not require .NET 5; they can be used with GA/RTM release of .NET Core 3.1.


Documentation and feedback

EF Core docs has a new landing page! The main page for Entity Framework documentation has been overhauled to provide you with a hub experience. We hope this new format helps you find the documentation you need faster and with fewer clicks.

The starting point for all EF Core documentation is docs.microsoft.com/ef/.

Please file issues found and any other feedback on the dotnet/efcore GitHub repo.


The following short links are provided for easy reference and access.

Main documentation: https://aka.ms/efdocs

Issues and feature requests for EF Core: https://aka.ms/efcorefeedback

Entity Framework Roadmap: https://aka.ms/efroadmap

What’s new in EF Core 5.x? https://aka.ms/efcore5


Thank you from the team

A big thank you from the EF team to everyone who has used EF over the years!

ajcvickers Arthur VickersAndriySvyryd Andriy Svyryd Brice LambsonJeremyLikness Jeremy Likness
lajones lajonesmaumar Maurycy Markowskiroji Shay Rojanskysmitpatel Smit Patel

Thank you to our contributors!

A big thank you to the following community members who have already contributed code or documentation to the EF Core 5 release! (List is in chronological order of first contribution to EF Core 5).

aevitas aevitasalaatm Alaa Masoudaleksandar-manukov Aleksandar Manukovamrbadawy Amr Badawy
AnthonyMonterrosa Anthony Monterrosabbrandt Ben Brandtbenmccallum Ben McCallumccjx Clarence Cai
CGijbels Christophe Gijbelscincuranet Jiri CincuraCosto Vincent Costeldshuvaev Dmitry Shuvaev
EricStG Eric St-GeorgesErikEJ Erik Ejlskov Jensengravbox Christopher Davisivaylokenov Ivaylo Kenov
jfoshee Jacob Fosheejmzagorski Jeremy Zagorskijviau Jacob Viauknom Max K.
lohoris-crane lohoris-craneloic-sharma Loïc Sharmalokalmatador lokalmatadormariusGundersen Marius Gundersen
Marusyk Roman Marusykmatthiaslischka Matthias LischkaMaxG117 MaxG117MHDuke MHDuke
mikes-gh Mike SurcoufMuppets Neil Bostromnmichels Nícolas MichelsOOberoi Obi Oberoi
orionstudt Josh Studtozantopal Ozan Topalpmiddleton Paul Middletonprog-rajkamal Raj
ptjhuang Peter Huangralmsdeveloper Rafael Almeida Santosredoz Patrik Husfloenrmarskell Richard Marskell
sguitardude sguitardudeSimpleSamples Sam Hobbssvengeance SvenVladDragnea Vlad
vslee vsleeWeihanLi liweihanYoussef1313 Youssef Victor1iveowl 1iveowl
thomaslevesque Thomas Levesqueakovac35 Aleksander Kovačleotsarev Leonid Tsarevkostat Konstantin Triger
sungam3r Ivan Maximovdzmitry-lahoda Dzmitry LahodaLogerfo Bruno Logerfowitheej Josh Withee
FransBouma Frans BoumaIGx89 Matthew Liederpaulomorgado Paulo Morgadomderriey Mickaël Derriey
LaurenceJKing Laurence Kingoskarj Oskar Josefssonbdebaere bdebaereBhargaviAnnadevara-MSFT Bhargavi Annadevara
AlexanderTaeschner Alexander TäschnerJesse-Hufstetler Jesse Hufstetler

13 comments

Comments are closed. Login to edit/delete your existing comments

  • Avatar
    Ian Marteens

    Is it me the only one who does not see any significant progress in EF from release to release? For instance, when will be able to use stored procedures in updates?

    • Avatar
      Calvin Nel

      Although i agree on, seems to be very minor updating…between releases.

      i don’t really agree with “stored procedures in updates?” , you should be more clear with what you feature you are referring to.
      (As there was stuff added ages ago that may or may not cover this.)

      Also depending on what you mean but SP’s kind of defeat the whole point of EF.

      …. progress is progress, would like to see more features from ef6 make its way through.
      Namely the ordering on columns when using code first.

      Good stuff non the less keep up the work!

      • Avatar
        Ian Marteens

        Store procedures in updates: EF 6 allows you to substitute the plain “update”, “insert” o “delete” from the ORM by calls to stored procedures.

        “but SP’s kind of defeat the whole point of EF”: store procedures are more efficient than SQL generated on the fly and open the door to true encapsulation of the database and a better security paradigm.

        • Avatar
          Calvin Nel
          • In Ef core you can still execute raw sql just like in EF6.

          • quote “store procedures are more efficient than SQL generated on the fly
            and open the door to true encapsulation of the database and a better security paradigm.”

          When query is complex, sure creating a SP will probably save you time and yield you the performance you wanting much quicker when complex, as it doesn’t have to be check for interpreted and checked.

          C is more efficient than c# (im just trying to show that where is a different way of thinking about it)

          IQueryable and dynamic Expression tree’s are extremely powerful and allow for very “on the fly” dynamic generation.

          EF is an encapsulation of the database so you can swap database providers with little to no effort.

          “better security paradigm.”
          personally i would think it the opposite.
          i dont actually know enough technically on this.
          i know for at least 1 point , Ef makes it safe from sql injection.
          Perhaps you could share why you think this is true.

          Sp have advantages sure.. like inplaces alters/changes… but beyond this…
          maybe your experience with EF as a tool is perhaps limited.

    • Avatar
      Tyler

      EF Core 3.0 had “significant progress” that utterly destroyed performance for queries in our application. So much so that we elected to stay on 2.2. I can do without any more “significant progress” from these guys.

  • Avatar
    Christian Fosli

    Cool 😊

    I wonder if the new record types introduced in C# 9 will work with EF Core 5 out of the box…
    I imagine these will be useful particularly for owned entities.

  • Avatar
    Jon Miller

    I love the part about depending on the plans for .NET 5 you may drop support for .NET Core 3.1. Kind of like what you did with dropping .NET Framework. I think you are wrong to require .NET Standard 2.1. You should go back to 2.0 for compatibility and to allow .NET Framework apps to use it. What are you going to do next, make it so that unless you are on the latest minor version of .NET, it won’t work? After all the years of breaking changes in EF, this is ridiculous.

    • Jeremy Likness
      Jeremy LiknessMicrosoft employee

      Entity Framework 6 was built to provide a bridge between .NET Framework and .NET Core and is production-ready and supported.

      EF Core 5 will only require .NET 5 if it is necessary to take advantage of new runtime features. The dependency on .NET 5 would not be a breaking change by itself, it would just mean you need to use .NET 5 if you want to migrate to EF Core 5. It doesn’t mean your EF Core 3 code won’t migrate forward.

      The team is passionate about preserving as much backwards compatibility with EF Core 3 as possible to ensure the migration is straightforward.