Skip to content

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

@ksusac

Description

@ksusac

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions