Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Nov 17, 2025

Fixes #37176 for EF 8.0 (see #37183 for 8.0 fix)

Description

C# 14 first-class spans causes MemoryExtensions.Contains instead of Enumerable.Contains to be resolved, forcing LINQ providers to identify the former in additional to the latter. In addition, .NET 10 introduced a 3-parameter overload to MemoryExtensions.Contains which accepts a comparer, that gets resolved in some situations. While we already backported support for MemoryExtensions.Contains to EF Core 8 and 9, to allow these versions to work with C# 14, we didn't backport a separate change to also support the new .NET 10 overload.

Customer impact

Customers upgrading to .NET 10 but staying on EF 8 or 9 start experiencing failures in some LINQ queries that use Contains. The common case is Contains over an enum array:

_ = await context.Blogs
    .Where(b => new SomeEnum[] { SomeEnum.One, SomeEnum.Too }.Contains(b.SomeEnum))
    .ToListAsync();

Customers upgrading to EF 10 are not affected.

How found

Multiple customers reported on 9.0

Regression

Partial: occurs only when upgrading to .NET 10 but keeping older EF 8 or 9.

Testing

Tested manually, as we don't have automated testing for .NET 10 on older EF versions.

Risk

Very low, targeted change that's very low-risk, and already well-tested in EF 10. Quirk added.

@roji roji requested review from a team and artl93 November 17, 2025 06:56
@roji
Copy link
Member Author

roji commented Nov 17, 2025

/cc @artl93 for initial servicing approval.

@artl93
Copy link
Member

artl93 commented Nov 17, 2025

Approved for me.

How often do we see regressions like this across versions of .NET?

@artl93
Copy link
Member

artl93 commented Nov 17, 2025

With the changes needed, should we be running a full test pass on 9.0 and 8.0 - like mock it up in a PR?

@roji
Copy link
Member Author

roji commented Nov 17, 2025

How often do we see regressions like this across versions of .NET?

Very rarely... There's an inherent increased brittleness with metaprogramming techniques (LINQ providers, Roslyn analyzers/source generators) which operate on representations of user code: any change in overload resolution or similar change in the code representation can trigger a failure. But we almost never see actual such breaks across .NET versions.

With the changes needed, should we be running a full test pass on 9.0 and 8.0 - like mock it up in a PR?

Yeah, that's a good idea - though it seems like it's a bit complicated/non-trivial to have our CI do EF8/9 with .NET 10 (see #37186). I ran some relevant testing locally and will also do the entire SQLite/SQL Server test suites.

@ChrisJollyAU
Copy link
Contributor

Looks good to me

Comment on lines +37 to +38
private static readonly bool UseOldBehavior37176 =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue37176", out var enabled37176) && enabled37176;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just reuse the above one? Seems like overkill to add a switch for each method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well technically these are two separate changes... this new one only fixes additional recognition for MemoryExtensions.Contains, and in theory could be problematic, causing users to need to roll back without also rolling back the general MemoryExtensions.Contains support.

I tend not to worry too much about quirks (they're in servicing branches only), but if you really prefer it I'll remove the new switch and keep only the existing one for MemoryExtensions.Contains.

This was referenced Jan 19, 2026
renebentes pushed a commit to renebentes/3054 that referenced this pull request Jan 20, 2026
#99)

Updated
[Microsoft.EntityFrameworkCore.Sqlite](https://github.com/dotnet/efcore)
from 9.0.11 to 9.0.12.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.EntityFrameworkCore.Sqlite's
releases](https://github.com/dotnet/efcore/releases)._

## 9.0.12

[Release](https://github.com/dotnet/core/releases/tag/v9.0.12)

## What's Changed
* [release/8.0-staging] Merge release/8.0 to release/8.0-staging by
@​cincuranet in dotnet/efcore#36948
* [release/9.0-staging] Merge release/9.0 to release/9.0-staging by
@​cincuranet in dotnet/efcore#36949
* [release/8.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/efcore#36980
* [release/9.0] Update Microsoft.Build.* versions by @​AndriySvyryd in
dotnet/efcore#37004
* [release/9.0] Merge release/9.0-staging to release/9.0 by
@​AndriySvyryd in dotnet/efcore#37041
* [release/8.0] Update dependencies by @​AndriySvyryd in
dotnet/efcore#37048
* Update branding to 8.0.23 by @​vseanreesermsft in
dotnet/efcore#37074
* [automated] Merge branch 'release/8.0' => 'release/9.0' by
@​github-actions[bot] in dotnet/efcore#37080
* [automated] Merge branch 'release/8.0-staging' => 'release/8.0' by
@​AndriySvyryd in dotnet/efcore#37079
* Update branding to 9.0.12 by @​vseanreesermsft in
dotnet/efcore#37075
* [release/9.0-staging] Fix 0-byte reads/writes on blobs by @​cincuranet
in dotnet/efcore#37068
* [release/8.0-staging] Fix 0-byte reads/writes on blobs by @​cincuranet
in dotnet/efcore#37067
* [automated] Merge branch 'release/8.0' => 'release/9.0' by
@​github-actions[bot] in dotnet/efcore#37088
* [release/8.0] Update BinSkim to 4.3.1 by @​AndriySvyryd in
dotnet/efcore#37091
* [release/9.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/efcore#37116
* Merging internal commits for release/8.0 by @​vseanreesermsft in
dotnet/efcore#37130
* Merging internal commits for release/9.0 by @​vseanreesermsft in
dotnet/efcore#37129
* [release/8.0] Change NuGet audit to moderate by @​AndriySvyryd in
dotnet/efcore#37138
* [automated] Merge branch 'release/8.0' => 'release/9.0' by
@​github-actions[bot] in dotnet/efcore#37135
* [release/8.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/efcore#37160
* [release/9.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/efcore#37161
* [automated] Merge branch 'release/8.0' => 'release/9.0' by
@​github-actions[bot] in dotnet/efcore#37163
* [release/9.0-staging] Handle .NET 10 MemoryExtensions.Contains
overload with comparer by @​roji in
dotnet/efcore#37183
* [release/8.0-staging] Handle .NET 10 MemoryExtensions.Contains
overload with comparer by @​roji in
dotnet/efcore#37182
* [release/8.0-staging] Update to Mac 15 queues. by @​cincuranet in
dotnet/efcore#37097
* [release/9.0-staging] Update to Mac 15 queues. by @​cincuranet in
dotnet/efcore#37098
* Merge release/8.0-staging to release/8.0 by @​AndriySvyryd in
dotnet/efcore#37305
* [release/9.0] Fix snapshot generation to capture column type for JSON
columns by @​Copilot in dotnet/efcore#37294
* Merge release/9.0-staging to release/9.0 by @​AndriySvyryd in
dotnet/efcore#37306
* [release/9.0] Update dependencies from dotnet/arcade by
@​dotnet-maestro[bot] in dotnet/efcore#37315
* [automated] Merge branch 'release/8.0' => 'release/9.0' by
@​github-actions[bot] in dotnet/efcore#37307


**Full Changelog**:
dotnet/efcore@v9.0.11...v9.0.12

Commits viewable in [compare
view](dotnet/efcore@v9.0.11...v9.0.12).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Microsoft.EntityFrameworkCore.Sqlite&package-manager=nuget&previous-version=9.0.11&new-version=9.0.12)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants