-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Description
Bug description
We released the first EF 10 version of our application today, and quickly hit this error. This is a query that works fine prior to EF 10, but now gives an InvalidOperationException, and suggests switching to client evaluation (not relevant to this query). I've attached a project with a cut down version of the entities that illustrates the issue
Notes:
- You don't need anything in the database since it doesn't get that far. Just set the connection string to any database you can access
- Change the EF versions in the project file to 9.0.11 to see it working - well, without database records you'll still get an error, but this time it will have accessed the database before failing, and will report it can't find the table
- Strangely, if you remove any two of the SetProperty calls (leaving a single one) it will work as well. The method that highlighted this error had other ExecuteUpdates setting more than one property, and these worked. They didn't include a SelectMany though?
- I can't seem to select Net10 and VS2026 in the options for this report, so they incorrectly state Net9 and VS2022
Your code
var qry = session.BookingLegs.Where(x => x.Prefix=="ZZ" && x.ID==0);
var strConfirmedBy = "Test";
qry.SelectMany(x => x.Booking.GatehouseEvents.Where(g => g.IsInGate && g.BookingLegID == null && g.Confirmed == null))
.ExecuteUpdate(str => str
.SetProperty(p => p.Confirmed, DateTime.Now)
.SetProperty(p => p.ConfirmTime, DateTime.Now)
.SetProperty(p => p.ConfirmedBy, strConfirmedBy)
);Stack traces
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitParameter(ParameterExpression parameterExpression)
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitMember(MemberExpression memberExpression)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.<>c__DisplayClass107_0.<TryTranslateSetters>g__TryTranslateMemberAccess|9(Expression expression, Expression& translation, IPropertyBase& property)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TryTranslateSetters(ShapedQueryExpression source, IReadOnlyList`1 setters, IReadOnlyList`1& columnSetters, TableExpressionBase& targetTable)
at Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerQueryableMethodTranslatingExpressionVisitor.TryTranslateSetters(ShapedQueryExpression source, IReadOnlyList`1 setters, IReadOnlyList`1& columnSetters, TableExpressionBase& targetTable)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.<TranslateExecuteUpdate>g__PushdownWithPkInnerJoinPredicate|105_0(<>c__DisplayClass105_0& )
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateExecuteUpdate(ShapedQueryExpression source, IReadOnlyList`1 setters)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.Translate(Expression expression)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_0`1.<ExecuteCore>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteUpdate[TSource](IQueryable`1 source, Action`1 setPropertyCalls)
at Program.<Main>$(String[] args) in C:\Users\kevino\source\repos\EF10Issue\Program.cs:line 10
Verbose output
EF Core version
10.0.0
Database provider
No response
Target framework
No response
Operating system
No response
IDE
No response