This is a cache of https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-ef-core.html. It is a snapshot of the page at 2024-10-06T01:02:30.245+0000.
Entity Framework Core | APM .NET Agent Reference [1.x] | Elastic

Entity Framework Core

edit

Quick start

edit

Instrumentation can be enabled for Entity Framework Core by referencing Elastic.Apm.EntityFrameworkCore package and passing EfCoreDiagnosticsSubscriber to the UseElasticApm method in case of ASP.NET Core as following

app.UseElasticApm(Configuration, new EfCoreDiagnosticsSubscriber()); 

Configuration is the IConfiguration instance passed to your Startup type

or passing EfCoreDiagnosticsSubscriber to the Subscribe method

Agent.Subscribe(new EfCoreDiagnosticsSubscriber());

Instrumentation listens for diagnostic events raised by Microsoft.EntityFrameworkCore 2.x+, creating database spans for executed commands.