Skip to content

Set SQL connection registered application for EF Core telemetry - #39698

Merged
cheenamalhotra merged 1 commit into
mainfrom
dev/cheena/sql-connection-telemetry
Nov 17, 2026
Merged

cheenamalhotra merged 1 commit into
mainfrom
dev/cheena/sql-connection-telemetry

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Set SqlConnection.RegisteredApplication to RegisteredApplication.EntityFrameworkCore when EF creates runtime, master, and reverse-engineering connections so SqlClient reports EF Core telemetry. Caller-supplied connections remain unchanged, since they may already be open.

Fixes #39699

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

Validation: dotnet test .\test\EFCore.SqlServer.Tests\EFCore.SqlServer.Tests.csproj -- --filter-method "*SqlServerConnectionTest.*" passed (9 tests). This command built the affected projects; the full suite and CI checks have not been run locally.

- Identify EF-created runtime and scaffolding connections as EntityFrameworkCore
- Preserve caller-provided connection identities and cover runtime and master connections

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the SQL Server connection telemetry changes.

No open issues 🎉

What changed in this PR

Addresses #39699 by identifying EF Core-created SQL Server connections in SqlClient telemetry while leaving caller-supplied connections unchanged.

Changes:

  • Sets RegisteredApplication.EntityFrameworkCore for runtime connections, including master connections.
  • Applies the same setting to reverse-engineering connections created from connection strings.
  • Adds assertions for runtime and master telemetry settings and preservation of caller-supplied values.
File Description
test/​EFCore.SqlServer.Tests/​Storage/​Internal/​SqlServerConnectionTest.cs Verifies telemetry settings and preservation of caller-supplied values.
src/​EFCore.SqlServer/​Storage/​Internal/​SqlServerConnection.cs Sets the telemetry identity when creating runtime and master SQL connections.
src/​EFCore.SqlServer/​Scaffolding/​Internal/​SqlServerDatabaseModelFactory.cs Sets the telemetry identity for factory-created reverse-engineering connections.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage

main 5bfb0ba dev/cheena/sql-conne... d0a7e4e +/-
76% 76% 0%
View coverage of the 10 most impacted files.
File main 5bfb0ba dev/cheena/sql-conne... d0a7e4e +/-
src/EFCore.Rela...CommandCache.cs 100% 98% -2%
src/EFCore.Anal...icSuppressor.cs 96% 96% 0%
src/EFCore.Cosm...erExtensions.cs 100% 100% 0%
src/EFCore.Cosm...nsExtensions.cs 82% 82% 0%
src/EFCore.Cosm...erExtensions.cs 46% 46% 0%
src/EFCore.Cosm...peExtensions.cs 73% 73% 0%
src/EFCore.Cosm...StreamHelper.cs 87% 87% 0%
src/EFCore.Cosm...delValidator.cs 98% 98% 0%
src/EFCore.Cosm...orConvention.cs 94% 94% 0%
src/EFCore.Rela...alConnection.cs 93% 94% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@cheenamalhotra
cheenamalhotra merged commit 10b9fb1 into main Nov 17, 2026
27 checks passed
@cheenamalhotra
cheenamalhotra deleted the dev/cheena/sql-connection-telemetry branch November 17, 2026 21:57
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set SqlConnection.RegisteredApplication to identify EF Core telemetry

3 participants