-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property using Enum with ExecuteUpdateAsync throws 'Object reference not set to an instance of an object.' #35656
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
preview-2
regression
type-bug
Milestone
Comments
Confirmed regression in 9, still occurs in latest main as well. This is very related to #35095 which was fixed for 9.0.1, but that fix did not cover cases where the coalesce expressoin in question was itself the top of an evaluatable tree, as is the case here (it's the lambda body). Minimal reproawait using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
AuthType? authType = AuthType.Bar;
await context.ImportJobs
.ExecuteUpdateAsync(q => q.SetProperty(q => q.AuthType, q => authType ?? q.AuthType));
public class BlogContext : DbContext
{
public DbSet<ImportJob> ImportJobs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
}
public class ImportJob
{
public int Id { get; set; }
public AuthType AuthType { get; set; }
}
public enum AuthType { Foo, Bar } |
roji
added a commit
to roji/efcore
that referenced
this issue
Feb 20, 2025
Reopening to consider patching for 9.0. |
roji
added a commit
to roji/efcore
that referenced
this issue
Mar 3, 2025
…net#35657) Fixes dotnet#35656 (cherry picked from commit c54f51d)
roji
added a commit
to roji/efcore
that referenced
this issue
Mar 3, 2025
Fixes dotnet#35656 (cherry picked from commit c54f51d)
roji
added a commit
to roji/efcore
that referenced
this issue
Mar 3, 2025
Fixes dotnet#35656 (cherry picked from commit c54f51d)
roji
added a commit
to roji/efcore
that referenced
this issue
Mar 4, 2025
Fixes dotnet#35656 (cherry picked from commit c54f51d)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
preview-2
regression
type-bug
Bug description
When running the code below, the error is always thrown. AuthType is a enum type. In ef 8, this worked without an issue. Upgrading to ef 9, now throws an error. If we move the coalesce out to a variable, and use the variable in the method, all works as normal. But this means we now need to pull down a copy of the row to get the value to coalesce with.
Your code
Stack traces
Verbose output
EF Core version
9.0.2
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.Net 8
Operating system
No response
IDE
No response
The text was updated successfully, but these errors were encountered: