You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Filter on JSON complex property over a LEFT JOIN drops unmatched rows #39523
Filter on JSON complex property over a LEFT JOIN drops unmatched rows
When an entity with a JSON complex property (ComplexProperty(...).ToJson()) is on the optional side of a LEFT JOIN, filtering on a property of that complex type loses the null compensation. Rows with no match are dropped.
Models
publicclassBlog{publicintId{get;set;}publicDetailsDetails{get;set;}}publicclassDetails{publicstringCity{get;set;}}modelBuilder.Entity<Blog>().ComplexProperty(b =>b.Details).ToJson();context.Blogs.AddRange(newBlog{Id=1,Details=newDetails{City="Sydney"}},newBlog{Id=2,Details=newDetails{City="Berlin"}});awaitcontext.SaveChangesAsync();varids=await(fromoincontext.Blogs
join nincontext.Blogs on o.Id+1 equals n.Id into nextfromninnext.DefaultIfEmpty()wheren!.Details.City!="Berlin"selecto.Id).ToListAsync();
Result
Expected:[2]. Blog 2 has no next blog, so n is null and the predicate is true.
SQLite behaves the same ("b0"."Details" ->> 'City' <> 'Berlin'). So does a subquery as the inner source, e.g. context.Blogs.OrderBy(b => b.Id).Take(5).
EF Core main (12.0.0-alpha), SQL Server and SQLite.
The below is an AI-generated analysis and may contain inaccuracies.
Issue:#39523 Mode: Normal. Safety scan completed on the issue, full discussion, and linked PR material. Reconstructed the inline case in an isolated console project, using synthetic data and SQLite in-memory only; no reporter-supplied project, scripts, or external database were used.
Recommendation: KEEP — high confidence. This is a confirmed incorrect-results regression between the tested EF Core 10 and 11 builds, also present in the tested 12 alpha. This independently corroborates the existing maintainer comment. Retain issue type Bug, regression, area-query, and area-json; add area-complex-types. No provider label is warranted for a shared relational-pipeline problem reported on both SQL Server and SQLite. Leave the existing 11.0.1 milestone unchanged.
Reproduction and regression evidence
Executed the same minimized query and model on Windows x64, targeting net11.0, using SDK 11.0.100-rc.1.26420.103 and runtime .NET 12.0.0-alpha.1.26456.102 (DOTNET_ROLL_FORWARD=LatestMajor). The SQLite engine was held at 3.53.4, with SQLitePCLRaw.bundle_e_sqlite3 pinned to 3.0.5 for every run. EF Core and Microsoft.EntityFrameworkCore.Sqlite versions were matched:
EF Core / provider
Actual IDs
Null compensation
10.0.14
[2] — correct
OR "b0"."Details" ->> 'City' IS NULL present
11.0.0-rc.3.26522.148
[] — incorrect
Missing
12.0.0-alpha.1.26473.114
[] — incorrect
Missing
For each version, dotnet build .\Repro.csproj -p:EfVersion=<version> --nologo --verbosity quiet succeeded, then dotnet .\bin\Debug\net11.0\Repro.dll executed successfully and produced the results above. The project references Microsoft.EntityFrameworkCore.Sqlite at $(EfVersion) and the pinned SQLite bundle. These are execution results, not just ToQueryString() inspection.
This establishes the regression interval, not the introducing commit or first affected preview. SQL Server, nested properties, and the Take subquery variant were not independently executed in this triage. The tested 12 alpha is not a build of current main.
minimal repro
usingMicrosoft.EntityFrameworkCore;usingMicrosoft.Extensions.Logging;awaitusingvarcontext=newTestContext();awaitcontext.Database.OpenConnectionAsync();awaitcontext.Database.EnsureCreatedAsync();context.Blogs.AddRange(newBlog{Id=1,Details=newDetails{City="Sydney"}},newBlog{Id=2,Details=newDetails{City="Berlin"}});awaitcontext.SaveChangesAsync();varids=await(fromoincontext.Blogs
join nincontext.Blogs on o.Id+1 equals n.Id into nextfromninnext.DefaultIfEmpty()wheren!.Details.City!="Berlin"selecto.Id).ToListAsync();Console.WriteLine($"Result: [{string.Join(", ",ids)}]");publicclassTestContext:DbContext{publicDbSet<Blog>Blogs=>Set<Blog>();protectedoverridevoidOnConfiguring(DbContextOptionsBuilderoptionsBuilder)=>optionsBuilder.UseSqlite("Data Source=:memory:").LogTo(Console.WriteLine,LogLevel.Information);protectedoverridevoidOnModelCreating(ModelBuildermodelBuilder)=>modelBuilder.Entity<Blog>().ComplexProperty(b =>b.Details).ToJson();}publicclassBlog{publicintId{get;set;}publicDetailsDetails{get;set;}=null!;}publicclassDetails{publicstringCity{get;set;}=null!;}
Source assessment and existing fix
The inspected source supports the proposed diagnosis:
JsonQueryExpression.BindProperty derives scalar nullability from the JSON query and property metadata. Leaving the JSON query/column non-nullable allows the null-semantics pass to omit compensation for the null-extended join row.
The existing open PR #39524 directly addresses that gap by calling JsonQueryExpression.MakeNullable(). Its diff includes direct-property, nested-property, and left-joined Take subquery regression cases, with SQLite and SQL Server baselines. It is not merged and no released fix is established. At inspection, SQLite and SQL Server checks passed, while the Main checks failed on all three platforms; their causes were not investigated here. The patch itself was not executed locally.
Duplicate search and next steps
Searched open and closed EF Core issues for "JSON" "null compensation", "complex" "LEFT JOIN", "JsonScalarExpression" "nullable", and "JSON" "compensation" "join". No confirmed duplicate was found. Related but distinct:
Proceed with review of #39524, resolve or explain its failing Main checks, and confirm the three regression cases on the intended 11.0.1 servicing branch as well as main. No additional reporter information is needed for the reproduced direct-property case. This triage does not close the issue or change its assignment or milestone.
Activity
cincuranet commentedon Nov 5, 2026
Regression in 11.
10.0.14:
11.0.0-rc.3.26522.148:
cincuranet commentedon Nov 5, 2026
AI Triage
The below is an AI-generated analysis and may contain inaccuracies.
Issue: #39523
Mode: Normal. Safety scan completed on the issue, full discussion, and linked PR material. Reconstructed the inline case in an isolated console project, using synthetic data and SQLite in-memory only; no reporter-supplied project, scripts, or external database were used.
Recommendation: KEEP — high confidence. This is a confirmed incorrect-results regression between the tested EF Core 10 and 11 builds, also present in the tested 12 alpha. This independently corroborates the existing maintainer comment. Retain issue type Bug,
regression,area-query, andarea-json; addarea-complex-types. No provider label is warranted for a shared relational-pipeline problem reported on both SQL Server and SQLite. Leave the existing 11.0.1 milestone unchanged.Reproduction and regression evidence
Executed the same minimized query and model on Windows x64, targeting
net11.0, using SDK11.0.100-rc.1.26420.103and runtime.NET 12.0.0-alpha.1.26456.102(DOTNET_ROLL_FORWARD=LatestMajor). The SQLite engine was held at 3.53.4, withSQLitePCLRaw.bundle_e_sqlite3pinned to 3.0.5 for every run. EF Core and Microsoft.EntityFrameworkCore.Sqlite versions were matched:[2]— correctOR "b0"."Details" ->> 'City' IS NULLpresent[]— incorrect[]— incorrectFor each version,
dotnet build .\Repro.csproj -p:EfVersion=<version> --nologo --verbosity quietsucceeded, thendotnet .\bin\Debug\net11.0\Repro.dllexecuted successfully and produced the results above. The project referencesMicrosoft.EntityFrameworkCore.Sqliteat$(EfVersion)and the pinned SQLite bundle. These are execution results, not justToQueryString()inspection.This establishes the regression interval, not the introducing commit or first affected preview. SQL Server, nested properties, and the
Takesubquery variant were not independently executed in this triage. The tested 12 alpha is not a build of current main.minimal repro
Source assessment and existing fix
The inspected source supports the proposed diagnosis:
StructuralTypeProjectionExpression.MakeNullablecallsMakeNullable()on complex-property shapers.RelationalStructuralTypeShaperExpression.MakeNullablepropagates nullability into a complex type'sStructuralTypeProjectionExpression, but not itsJsonQueryExpression.JsonQueryExpression.BindPropertyderives scalar nullability from the JSON query and property metadata. Leaving the JSON query/column non-nullable allows the null-semantics pass to omit compensation for the null-extended join row.The existing open PR #39524 directly addresses that gap by calling
JsonQueryExpression.MakeNullable(). Its diff includes direct-property, nested-property, and left-joinedTakesubquery regression cases, with SQLite and SQL Server baselines. It is not merged and no released fix is established. At inspection, SQLite and SQL Server checks passed, while the Main checks failed on all three platforms; their causes were not investigated here. The patch itself was not executed locally.Duplicate search and next steps
Searched open and closed EF Core issues for
"JSON" "null compensation","complex" "LEFT JOIN","JsonScalarExpression" "nullable", and"JSON" "compensation" "join". No confirmed duplicate was found. Related but distinct:EF.Constant(), rather than the missing nullable JSON complex shaper.Proceed with review of #39524, resolve or explain its failing Main checks, and confirm the three regression cases on the intended 11.0.1 servicing branch as well as main. No additional reporter information is needed for the reproduced direct-property case. This triage does not close the issue or change its assignment or milestone.