-
Type:
Bug
-
Resolution: Done
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Dotnet Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Remainder of EF-255 (triaged 2026-09-30). Random.Next(...) and Guid.NewGuid() now throw in a predicate, ordering or projection. These do not: Random.Shared.NextDouble(), NextSingle(), NextInt64() and Guid.CreateVersion7(). EF Core turns them into query parameters before the provider sees the expression, so they are evaluated once per execution and the same value is used for every row. Silent wrong result in all query modes.
Repro
var r = context.Entities.Select(e => new { e.Id, R = Random.Shared.NextDouble() }).ToList(); // every row has the same R (a fresh value on each execution) var w = context.Entities.Where(e => e.D > Random.Shared.NextDouble()).ToList(); // all rows are compared against a single threshold
Notes
The Next-prefix match and the CreateVersion7 arm in NonDeterministicCalls never fire for these today because EF has already parameterized them. Options: detect the parameter extraction (query parameter whose expression is a non-deterministic call) and throw, or map NextDouble to the server rand operator. Both modes reach the same result, so a bridge-level or compiler-level check is needed rather than a method-call check.