Skip to content

SqlConnection.Clone doesn't copy AccessTokenCallback #2524

Closed

Description

@rayao

I'm not sure it's bug or by design, if by design, can you explain why?

Activity

  1. kf-gonzalez2 commented on May 22, 2024

    @kf-gonzalez2

    Can you please elaborate further on the issue? please include any repro steps or more explanation

  2. ErikEJ commented on May 22, 2024

    @ErikEJ
    Contributor

    @kf-gonzalez2 There is a originating issue here: ErikEJ/EntityFramework6PowerTools#147 and a follow up PR for EF 6 here: ErikEJ/EntityFramework6PowerTools#150 - I think this could be "by design"

  3. roji commented on May 22, 2024

    @roji
    Member

    FWIW I think the main usefulness in DbConnection.Clone() is precisely to clone the authentication information, so that the clone can actually be opened successfully. For example, the password does get copied to clones, so I'm not sure why AccessTokenCallback would be treated any differently:

    var connection1 = new SqlConnection("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false");
    connection1.Open();
    
    var connection2 = (SqlConnection)((ICloneable)connection1).Clone();
    connection2.Open();
  4. ErikEJ commented on May 22, 2024

    @ErikEJ
    Contributor

    @roji Thanks for joining! Yeah. could be an oversight - AccessTokenCallback was just added to 5.2.

    Would be great to get it fixed in SqlClient. so that Microsoft.EntityFramwork.SqlServer could take advantage (by using a newer SqlClient). I think adding the above "fix" to that is out of scope.

  5. David-Engel commented on May 22, 2024

    @David-Engel
    Contributor

    I agree, this seems to be a simple oversight in the original implementation. We should fix this in MDS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions