dotnet / dotnet/efcore

Include types in exception message for EF.Default failure

Open
#28,922 0 comments 0 reactions 0 assignees View on GitHub
area-query
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

See https://github.com/dotnet/efcore/issues/28921

```
warn: 8/30/2022 18:22:48.438 RelationalEventId.QueryPossibleUnintendedUseOfEqualsWarning[20501] (Microsoft.EntityFrameworkCore.Query)
Possible unintended use of method 'Equals' for arguments 'p.PublishedOn' and 'DEFAULT' of different types in a query. This comparison will always return false.
Unhandled exception. System.InvalidOperationException: The LINQ expression 'DbSet()
.ExecuteUpdate(setPropertyCalls => setPropertyCalls.SetProperty(
propertyExpression: post => post.PublishedOn,
valueExpression: post => EF.Default()))' could not be translated. Additional information: The following 'SetProperty' failed to translate: 'SetProperty(post => post.PublishedOn, post => EF.Default())'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
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__DisplayClass12_0`1.b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.RelationalQueryableExtensions.ExecuteUpdateAsync[TSource](IQueryable`1 source, Expression`1 setPropertyCalls, CancellationToken cancellationToken)
at NewInEfCore7.ExecuteUpdateSample.ResetPostPublishedOnToDefault[TContext]() in C:\github\EntityFramework.Docs\samples\core\Miscellaneous\NewInEFCore7\ExecuteUpdateSample.cs:line 182
at NewInEfCore7.ExecuteUpdateSample.ResetPostPublishedOnToDefault[TContext]() in C:\github\EntityFramework.Docs\samples\core\Miscellaneous\NewInEFCore7\ExecuteUpdateSample.cs:line 191
at NewInEfCore7.ExecuteUpdateSample.ExecuteUpdateTest[TContext]() in C:\github\EntityFramework.Docs\samples\core\Miscellaneous\NewInEFCore7\ExecuteUpdateSample.cs:line 59
at NewInEfCore7.ExecuteUpdateSample.ExecuteUpdateTest[TContext]() in C:\github\EntityFramework.Docs\samples\core\Miscellaneous\NewInEFCore7\ExecuteUpdateSample.cs:line 61
at Program.Main() in C:\github\EntityFramework.Docs\samples\core\Miscellaneous\NewInEFCore7\Program.cs:line 18
at Program.()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.