The new rule S6966 should be disabled for EF Core Add methods

The following methods should be suppressed for the new rule csharpsquid:S6966 “Awaitable method should be used”:

  • DbContext.Add
  • DbContext.AddRange
  • DbSet.Add
  • DbSet.AddRange

See Don´t emit CA1849 when using DbSet.Add and DbSet.AddRange EntityFramework Methods by Spacefish · Pull Request #6858 · dotnet/roslyn-analyzers · GitHub for a similar fix for the Roslyn analyzer rule CA1849 “Call async methods when in an async method”.

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable: SonarCloudAnalyze YAML task
  • Languages of the repository: C#
  • Error observed: csharpsquid:S6966 “Awaitable method should be used” is reported for EF Core AddRange methods.
  • Steps to reproduce: Add code that calls DbContext.AddRange
  • Potential workaround: -

Seems like this is already tracked in Fix S6966 FP: EntityFramework DbContext · Issue #9269 · SonarSource/sonar-dotnet · GitHub

1 Like