Search code examples
c#.netentity-framework-core.net-7.0ef-core-7.0

EF Core 7 no definition for ExecuteUpdateAsync


I have the following query in my project which is using Microsoft.EntityFrameworkCore 7.0.2:

await _context.Actions
    .Where(a => a.DateCreated < DateTime.Today && a.ActionType == (int)ActionTypes.ScoredAction && !a.DateCompleted.HasValue)
    .ExecuteUpdateAsync(b => b
        .SetProperty(x => x.DateCompleted, x => DateTime.Today)
        .SetProperty(x => x.ActionResultType, x => LeadScoringConstants.SystemClosed));

But when I try to build, it's saying that IQueryable<ActionEntity> doesn't contain a definition for ExecuteUpdateAsync. Am I missing something here as the documentation says it was added to EF Core 7


Solution

  • ExecuteUpdateAsync is part of the RelationalQueryableExtensions, do not forget to install corresponding nuget (i.e. Microsoft.EntityFrameworkCore.Relational).