Skip to content

Adopt Microsoft.Data.SqlClient instead of System.Data.SqlClient #16156

Closed

Description

@WeihanLi

Summary of the new feature / enhancement

Maybe we should consider using Microsoft.Data.SqlClient instead of System.Data.SqlClient

Proposed technical implementation details (optional)

No response

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Sep 26, 2021
  2. iSazonov commented on Sep 26, 2021

    @iSazonov
    Collaborator

    We can not remove System.Data.SqlClient, it will be a huge breaking change. Nevertheless we could add Microsoft.Data.SqlClient.
    System.Data.SqlClient.dll is ~1Mb. I guess Microsoft.Data.SqlClient too. We need to see important scenarios to add so large dll in distribution.

  3. ajansveld commented on Feb 10, 2022

    @ajansveld

    I believe we now have a compelling reason. Bugs are no longer being fixed in System.Data.SqlClient, only in Microsoft.Data.SqlClient.

    Case in point: #16567 was fixed (dotnet/SqlClient#1411) in Microsoft.Data.SqlClient, but this doesn't help PowerShell 7.2 users since it contains System.Data.SqlClient which will not be fixed.

    Adding Microsoft.Data.SqlClient and its dependencies to PowerShell will still require people to update their affected scripts, but that is much easier than trying to use it as a standalone package (because #6724).

  4. daxian-dbw commented on Feb 10, 2022

    @daxian-dbw
    Member

    Quoted from Introducing the new Microsoft.Data.SqlClient

    It means the development focus has changed. We have no intention of dropping support for System.Data.SqlClient any time soon. It will remain as-is and we will fix important bugs and security issues as they arise. If you have a typical application that doesn’t use any of the newest SQL features, then you will still be well served by a stable and reliable System.Data.SqlClient for many years.

    That means the System.Data.SqlClient will still be patched with security fixes, though not all bug fixes. So I guess it's fine to keep it in PowerShell, and add the new Microsoft.Data.SqlClient. Thoughts? Travis Plunk (@TravisEz13) Aditya Patwardhan (@adityapatwardhan) Paul Higinbotham (@PaulHigin)

  5. iSazonov commented on Feb 11, 2022

    @iSazonov
    Collaborator

    Maybe move System.Data.SqlClient to WinCompat and now start migration to Microsoft.Data.SqlClient since we are on new dev cycle (vNext is not LTS).

  6. kerbou commented on Nov 24, 2022

    @kerbou

    We would absolutely love to have Microsoft.Data.SqlClient available in Powershell - I'm part of a platform team and want to get rid of SQL Auth. completely in our infrastructure. Not having Microsoft.Data.SqlClient available to us in Powershell is currently blocking us from doing that as we need to authenticate a Powershell process using IAM in our CD pipelines and execute SQL scripts prior to doing database migrations.

    Right now, we're forced to stick with SQL Auth which is less than satisfying for us for various reasons - i.e. company compliance policies, just to name one of them

  7. ronascentes commented on Dec 7, 2022

    @ronascentes

    I would love to have Microsoft.Data.SqlClient in Powershell but I don't think that adding this .dll to code is the way to go. It would not fit with the open-source philosophy since this addition would only bring benefit to SQL Server, a Microsoft product. Since PowerShell was open sourced, we can see a lot of effort to make it more compatible with other non-Microsoft platforms. Like Python, or any other open-source programming language, we have to use libraries for this job and PowerShell has the modules. The preview v22 version of SqlServer module switches from System.Data.SqlClient to Microsoft.Data.SqlClient and we should use this module for new script developments for SQL Server.

  8. TravisEz13 commented on Feb 13, 2023

    @TravisEz13
    Member

    I would love to have Microsoft.Data.SqlClient in PowerShell but I don't think that adding this .dll to code is the way to go. It would not fit with the open-source philosophy since this addition would only bring benefit to SQL Server, a Microsoft product. Since PowerShell was open sourced, we can see a lot of effort to make it more compatible with other non-Microsoft platforms. Like Python, or any other open-source programming language, we have to use libraries for this job and PowerShell has the modules. The preview v22 version of SqlServer module switches from System.Data.SqlClient to Microsoft.Data.SqlClient and we should use this module for new script developments for SQL Server.

    I agree with this sentiment. The new Assembly is about 1.5MiB on Windows. These were included to not break existing scenarios. If the the scenario is new, we should move to a module based solution, and it looks like one already exists.

    From a security point of view, eventually, I believe we will eventually have to drop System.Data.SqlClient because of certain issues which cannot be fixe (I'm not predicting what they will be.)

  9. iSazonov commented on Mar 3, 2023

    @iSazonov
    Collaborator

    It is a time to consider the breaking change for 7.4. We have a time to get feedback before release.
    /cc Steve Lee (@SteveL-MSFT) Dongbo Wang (@daxian-dbw)

  10. JustinGrote commented on Dec 7, 2023

    @JustinGrote
    Contributor

    Steve Lee (@SteveL-MSFT) Ilya (@iSazonov) this came up in the PS discord today and already has a 7.4/NET8 breaking issue if someone tries to load SqlGuidCaster
    image

    Can you clarify this comment about how it is a huge breaking change? Other than maybe modules relying on the assembly in-built? I didn't see any direct references to the library in PowerShell itself.
    #16156 (comment)

    EDIT: Also Please reopen as active.

  11. marcinsmialek commented on Jan 4, 2024

    @marcinsmialek

    Such problems should be easier to deal with if C# / .NET NuGet packages were natively supported in PowerShell - #6724
    Perhaps it's an opportunity to reopen both issues?

  12. JustinGrote commented on Jan 4, 2024

    @JustinGrote
    Contributor

    marcinsmialek in this case it wouldn't, because it is natively bundled in PS you'd still have the assembly conflict until it is removed from being bundled in PS.

  13. rhubarb-geek-nz commented on May 21, 2024

    @rhubarb-geek-nz

    I have done some investigation packaging the new Microsoft.Data.SqlClient in its own AssemblyLoadContext. It appears to work well as it's own PSGallery module.

    I have a proof of concept on github and PSGallery

  14. elthombre commented on Feb 25, 2025

    @elthombre

    I need Microsoft.Data.SqlClient for a current automation against an Azure SQL database. I am having issues getting the package installed.

    What is the status of this? Is the Microsoft.Data.SqlClient fully supported in PowerShell and, if so, how to install it?

  15. JustinGrote commented on Feb 25, 2025

    @JustinGrote
    Contributor

    elthombre even though it is a "Microsoft" assembly, it is still considered a third party assembly, so it won't even be supported by the team in terms of directly fixing issues with it.

    In terms of "working" however, it should be loadable in PowerShell7 as per #16156 (comment), as he is doing the proper work of isolating common dependencies in an Assembly Load Context.

    So you can try his gallery module, but again, this would be community supported, not PowerShell team supported.

  16. elthombre commented on Feb 25, 2025

    @elthombre

    Justin Grote (@JustinGrote) , OK, interesting...

    It is my understanding that in order to support MFA, Azure-based SQL databases, etc., that this assembly is recommended/required.

    So, if it's not actually supported by Microsoft, what is? And what is recommended best practice/choice by Microsoft?

  17. JustinGrote commented on Feb 25, 2025

    @JustinGrote
    Contributor

    Justin Grote (@JustinGrote) , OK, interesting...

    It is my understanding that in order to support MFA, Azure-based SQL databases, etc., that this assembly is recommended/required.

    So, if it's not actually supported by Microsoft, what is? And what is recommended best practice/choice by Microsoft?

    It would be supported by the Microsoft team that provides the assembly, you would have to ask them, in the same way the Azure PowerShell module is owned by that Azure team and not the Powershell team itself.

  18. rhubarb-geek-nz commented on Feb 25, 2025

    @rhubarb-geek-nz

    It is my understanding that in order to support MFA, Azure-based SQL databases, etc., that this assembly is recommended/required.

    Hi, my PSGallery module is using the true Microsoft assembly. Does this not work? As mentioned it loads the assembly in its own ALC, this is the recommended approach in PowerShell to avoid conflicts.

  19. elthombre commented on Feb 26, 2025

    @elthombre

    OK, thanks.

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

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Review - MaintainerThe PR/issue needs a review from the PowerShell repo MaintainersWG-Maintainers-Buildspecific to affecting the build

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions