From 44eab7229a700014ef0d4ac8d4530ac0893cb2e5 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Tue, 30 Dec 2025 14:59:20 +0100 Subject: [PATCH 1/2] Inject SQL Server Application Name in a more robust way Fixes #37115 --- src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs index 382cc158a1e..d6ddb260020 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs @@ -173,7 +173,8 @@ protected virtual string ModifyConnectionString(string userProvidedConnectionStr // detect that and overwrite. if (connectionStringBuilder.ApplicationName is "Core Microsoft SqlClient Data Provider" or "" or null) { - var efVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion; + var efVersion = typeof(SqlServerConnection).Assembly + .GetCustomAttribute()?.InformationalVersion; _defaultApplicationName ??= $"EFCore/{efVersion} ({RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture})"; From e2b93e2913c701a10650dc632591ddf13876b4c2 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Tue, 30 Dec 2025 16:42:06 +0100 Subject: [PATCH 2/2] Update src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs index d6ddb260020..6b722dbaeb2 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs @@ -177,7 +177,7 @@ protected virtual string ModifyConnectionString(string userProvidedConnectionStr .GetCustomAttribute()?.InformationalVersion; _defaultApplicationName ??= - $"EFCore/{efVersion} ({RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture})"; + $"EFCore/{efVersion ?? "unknown"} ({RuntimeInformation.OSDescription} {RuntimeInformation.OSArchitecture})"; connectionStringBuilder.ApplicationName = _defaultApplicationName;