Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloneDbConnection handles AccessTokenCallback #150

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<PackageId>ErikEJ.EntityFramework.SqlServer</PackageId>
<PackageVersion>6.6.9</PackageVersion>
<PackageVersion>6.6.10</PackageVersion>
<Authors>ErikEJ</Authors>
<Description>SQL Server runtime provider for Entity Framework 6.4, using the Microsoft.Data.SqlClient ADO.NET provider.</Description>
<PackageProjectUrl>https://github.com/ErikEJ/EntityFramework6PowerTools</PackageProjectUrl>
<PackageReleaseNotes>Update to M.D.S. 5.1.5</PackageReleaseNotes>
<PackageReleaseNotes>Update to M.D.S. 5.2.0</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<MinClientVersion>5.0</MinClientVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down Expand Up @@ -113,7 +113,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.5" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,16 @@ public override DbConnection CloneDbConnection(DbConnection connection, DbProvid
DebugCheck.NotNull(connection);
DebugCheck.NotNull(factory);

if (connection is SqlConnection sqlConnection && sqlConnection.AccessTokenCallback != null)
{
// SqlConnection.Clone doesn't handle this case, so we special-case it here, if later it's fixed in
// Microsoft.Data.SqlCLient, we can remove this code piece. See https://github.com/dotnet/SqlClient/issues/2524
return new SqlConnection(sqlConnection.ConnectionString)
{
AccessTokenCallback = sqlConnection.AccessTokenCallback,
};
}

var clonableConnection = connection as ICloneable;
if (clonableConnection != null)
{
Expand Down
5 changes: 5 additions & 0 deletions src/ErikEJ.EntityFramework.SqlServer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ Please report any issues, questions and suggestions [here](https://github.com/Er

## Release notes

### 6.6.10

- Uses Microsoft.Data.SqlClient 5.2.0
- Work around issue https://github.com/dotnet/SqlClient/issues/2524 in CloneDbConnection

### 6.6.9

- Uses Microsoft.Data.SqlClient 5.1.5
Expand Down