Taras Kovalenko
Taras Kovalenko

Reputation: 2393

Safe migration to EF Core 3.0

I have been migrating my project from .net core 2.2 to 3.1 LTS and also update all nuget packages and following all this process I have saw that a lot of my Rest API endpoints stop working properly because of some issues with EF and DB.

Related to this article Breaking changes included in EF Core 3.0 right now we have tons of breaking changes which we must fix immediately (we can't just left it as it is) to successfully migrate to .net core 3.1 and EF 3.0.

The question is, how to do a safe migration to EF Core 3.0 and how to find all places where need to fix LINQ queries?

Upvotes: 1

Views: 442

Answers (1)

lauxjpn
lauxjpn

Reputation: 5254

The query pipeline was completely rewritten for EF Core 3.0, so technically there were many breaking changes.

In practice though, it comes down to a few that should be checked. Those are marked with a high impact. You can ignore the one about EF Core 3.0 and .NET Standard 2.1, because EF Core 3.1 was made compatible again with .NET Standard 2.0.

In most cases it comes down to only one breaking change with an actual impact:

LINQ queries are no longer evaluated on the client

This is the important one. Use AsEnumerable() or ToList() to explicitly switch to client-evaluation from that point in the query, or split your queries manually, where you use a lot of Include() calls that can lead to a cartesian explosion.

You could also wait for EF Core 5 (or use the latest preview now), that adds the feature of Split Queries, which is an improved version of what EF Core prior to 3.0 would do, that can explicitly be enabled for a query.

Upvotes: 2

Related Questions