Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 17, 2025

EF Core 10 changed the default translation of parameterized collections (e.g., .Contains() with variable lists) from JSON array parameters to multiple scalar parameters. This causes runtime errors like System.DivideByZeroException when collection sizes approach SQL Server's 2,100 parameter limit, but was undocumented in breaking changes.

Changes

  • Added "Parameterized collections now use multiple parameters by default" entry to breaking changes summary table
  • Added detailed breaking change section documenting:
    • Old behavior (EF9): JSON array with OPENJSON - WHERE [b].[Id] IN (SELECT [i].[value] FROM OPENJSON(@__ids_0)...)
    • New behavior (EF10): Multiple parameters - WHERE [b].[Id] IN (@ids1, @ids2, @ids3)
    • Runtime errors when approaching parameter limits
    • Parameter list padding behavior (e.g., 8 values → 10 parameters)
  • Documented three mitigation strategies:
    • Global configuration: UseParameterizedCollectionMode(ParameterTranslationMode.Constant)
    • Available modes: MultipleParameters (new default), Constant (pre-EF8), SingleJsonParameter (EF8-9)
    • Per-query override: EF.Constant(ids).Contains(b.Id)
  • Cross-referenced whatsnew documentation for complete translation details

Categorized as Low-impact, consistent with similar behavioral changes in the release.

Original prompt

This section details on the original issue you should resolve

<issue_title>Why isn’t “LINQ and SQL translation — improved translation for parameterized collections” mentioned in the breaking changes of EF CORE 10?</issue_title>
<issue_description>### Question

Why is the change in default behavior of .Contains() translation not mentioned under Breaking changes for EF Core 10? The same issue was noted in EF Core 8 when this functionality changed.

This change results in a runtime error, System.DivideByZeroException, when a query has a large number of parameters, approaching the 2,100 limit.

I’m sure we’re not the only ones checking the breaking-changes documentation to understand why queries that worked in EF Core 9 are now throwing exceptions.

Your code

var result = await _dbContext.SomeEntity
    .Where(d => ids.Contains(d.Id))
    .ToListAsync();

Stack traces

System.DivideByZeroException:
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor+<>c__DisplayClass33_0.<VisitIn>g__ProcessInExpressionValues|1 (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.VisitIn (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlNullabilityProcessor.VisitIn (Microsoft.EntityFrameworkCore.SqlServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.VisitExtension (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlNullabilityProcessor.VisitExtension (Microsoft.EntityFrameworkCore.SqlServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Process (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlNullabilityProcessor.Process (Microsoft.EntityFrameworkCore.SqlServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerParameterBasedSqlProcessor.ProcessSqlNullability (Microsoft.EntityFrameworkCore.SqlServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.RelationalParameterBasedSqlProcessor.Process (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerParameterBasedSqlProcessor.Process (Microsoft.EntityFrameworkCore.SqlServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.RelationalParameterBasedSqlProcessor.Process (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.Internal.RelationalCommandCache.GetRelationalCommandTemplate (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Internal.RelationalCommandResolverExtensions.RentAndPopulateRelationalCommand (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1+AsyncEnumerator+<InitializeReaderAsync>d__21.MoveNext (Microsoft.EntityFrameworkCore.Relational, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

Verbose output


EF Core version

10.0.0

Database provider

No response

Target framework

.NET 10

Operating system

No response

IDE

No response</issue_description>

<agent_instructions>Please add a low-impact breaking change note to the 10.0 breaking change, detailing the different default behavior around parameterized collections in EF 10 (the docs for this are in https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-10.0/whatsnew#improved-translation-for-parameteriz...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix breaking change documentation for .Contains() in EF Core 10 Document parameterized collection translation as breaking change in EF Core 10 Nov 17, 2025
Copilot AI requested a review from roji November 17, 2025 21:26
Copilot finished work on behalf of roji November 17, 2025 21:26
@roji roji requested a review from a team November 17, 2025 21:42
@roji roji force-pushed the copilot/fix-contains-translation-issue branch from 2fab2e8 to c156ea8 Compare November 17, 2025 21:43
@roji roji marked this pull request as ready for review November 17, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why isn’t “LINQ and SQL translation — improved translation for parameterized collections” mentioned in the breaking changes of EF CORE 10?

2 participants