Describe the bug
Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectionString always returns empty in .NET 6 target framework when using Microsoft.Data.SqlClient v6.1.x package.
To reproduce
Reproduce option 1:
Create a console csporj as below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.2" />
</ItemGroup>
</Project>
Program.cs:
var connstrBuilder = new Microsoft.Data.SqlClient.SqlConnectionStringBuilder("Data Source=localhost;");
Console.WriteLine($"Connection String: {connstrBuilder.ConnectionString}"); // returns empty string in net6.0 when using Microsoft.Data.SqlClient 6.1.x
Run the above program will output below message in console:
Connection String:
Reproduce option 2:
Run below command in bash under Linux with docker installed:
docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0 bash -c "\
dotnet new console -n demo && \
dotnet add demo package Microsoft.Data.SqlClient -v 6.1.2 && \
echo 'Console.WriteLine($\"Connection String: {new Microsoft.Data.SqlClient.SqlConnectionStringBuilder(\"Data Source=localhost;\").ConnectionString}\");' >> demo/Program.cs &&\
dotnet run -p demo; bash"
Expected behavior
The program should output below message in console:
Connection String: Data Source=localhost
Further technical details
Microsoft.Data.SqlClient version: 6.1.2
.NET target: .NET 6.0
SQL Server version: N/A
Operating system: Windows 10/11, Ubuntu 24.04 WSL, Docker container
Describe the bug
Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectionString always returns empty in .NET 6 target framework when using Microsoft.Data.SqlClient v6.1.x package.
To reproduce
Reproduce option 1:
Create a console csporj as below:
Program.cs:
Run the above program will output below message in console:
Connection String:Reproduce option 2:
Run below command in bash under Linux with docker installed:
Expected behavior
The program should output below message in console:
Connection String: Data Source=localhostFurther technical details
Microsoft.Data.SqlClient version: 6.1.2
.NET target: .NET 6.0
SQL Server version: N/A
Operating system: Windows 10/11, Ubuntu 24.04 WSL, Docker container