[release/9.0] Avoid using ^ and ~ when invalid because of value converters#35241
Merged
roji merged 1 commit intodotnet:release/9.0-stagingfrom Dec 2, 2024
Merged
[release/9.0] Avoid using ^ and ~ when invalid because of value converters#35241roji merged 1 commit intodotnet:release/9.0-stagingfrom
^ and ~ when invalid because of value converters#35241roji merged 1 commit intodotnet:release/9.0-stagingfrom
Conversation
…net#35124) The transformation of equality/in-equality in a (negated) XOR is only possible when the expressions are BIT or integer types on the SQL side (i.e. taking value conversion into account). Similarly, the Boolean negation `NOT` can be implemented as `~` only if the underlying expression is a BIT. Fixes dotnet#35093. (cherry picked from commit e6abfdd)
ajcvickers
approved these changes
Nov 30, 2024
Member
Author
|
Servicing approved via email. |
|
Sorry, team: is this fix already released to general audience? I upgraded my .NET 8 API project to .NET 9 today and immediately started getting loads of errors on SQL server side with this very issue in the scope. Since all of my EF statements are auto-generated with Hot Chocolate 14 instead of manually constructed, I have no control over it and rely on your fix in the EF Core that you were discussing. Is this already released and can be pulled via Nuget package update yet? |
Member
|
@SurgeOccm It will be released this month in 9.0.1 |
Thank you Andriy, very much appreciated! |
This was referenced Jul 22, 2025
This was referenced Feb 16, 2026
Bump Microsoft.EntityFrameworkCore.Design from 8.0.22 to 9.0.13
NatYou345/TailwindTraders-Backend#78
Open
Open
Open
Open
Closed
Closed
Closed
Closed
Open
This was referenced Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35093
Backports #35124
Description
EF 9 brings many improvements to SQL generation (list). One of these, which also improves query performance, applies bit arithmetic (XOR) to implement equality in contexts where SQL Server requires a BIT value (as opposed to a search condition, so projected SELECT values rather than WHERE predicates).
Unfortunately, the SQL optimization was implemented too widely, applying also on value-converted values, which is incorrect.
Customer impact
Queries on SQL Server which involve equality with a value-converted value sometimes generate invalid SQL and fail. For example:
This scenario is particularly common with value-converted enums, and so has the potential to affect many users. The fix is trivial and low-risk.
How found
Customer reported on 9.
Regression
Yes, from 8.
Testing
Tests added.
Risk
Low and quirked.
/cc @ranma42