KEMBAR78
Calls to `SaveChangesAsync` do not update the `EntityFrameworkEventSource` values · Issue #23604 · dotnet/efcore · GitHub
Skip to content

Calls to SaveChangesAsync do not update the EntityFrameworkEventSource values #23604

@meggima

Description

@meggima

Actual behavior

We use the new EntityFrameworkEventSource to collect metrics about EF Core performance.
However, the counters save-changes-per-second and total-save-changes constantly show a value of 0 for our application.

Expected behavior

We call await dbContext.SaveChangesAsync() in our code multiple times per second. So, we expect both values to be greater than zero.

Possible cause

I digged a bit into the source code and suspect that there's a bug here:

return await _database.SaveChangesAsync(entriesToSave, cancellationToken)

In the async overload of SaveChanges the call to the EventSource is missing. Compare

EntityFrameworkEventSource.Log.SavingChanges();

Environment information

EF Core version: 5.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: e.g. .NET 5.0
Operating system: Docker (Linux containers)
IDE: Visual Studio Enterprise 2019 16.8.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions