Skip to content

Microsoft.Data.SqlClient is not supported on this platform exception #2397

Closed as duplicate

Description

@DavoudEshtehari

Describe the bug

I've searched this repository along with the sqlclient repository. There are multiple issues bring this up but are either closed or solutions provided don't seem to fix the issue I'm getting.

I'm trying to create a basic binary module in PowerShell against SQL Server. I have a basic project structure with just one cmdlet so far (trying to see if this even works) that references SMO library.

Project: https://github.com/wsmelton/dbalight/tree/modulebuilder/source/dbalight

The project compiles for dotnet 6 on my M1 and the module imports with no issues. It is not until I call the Connect-DblServer:

Exception             : 
    Type       : System.PlatformNotSupportedException
    TargetSite : Void .ctor()
    Message    : Microsoft.Data.SqlClient is not supported on this platform.
    Source     : Microsoft.Data.SqlClient
    HResult    : -2146233031
    StackTrace : 
   at Microsoft.Data.SqlClient.SqlConnection..ctor()
   at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor(IRenewableToken token, Boolean removeIntegratedSecurity)
   at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor()
   at Microsoft.SqlServer.Management.Common.ServerConnection..ctor()
   at dbalight.cmdlets.general.ConnectServerCmdlet.ProcessRecord() in 
/Users/smelton/git/dbalight/source/dbalight/cmdlets/public/ConnectServer.cs:line 41
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Connect-DblServer], PlatformNotSupportedException
FullyQualifiedErrorId : System.PlatformNotSupportedException,dbalight.cmdlets.general.ConnectServerCmdlet
InvocationInfo        : 
    MyCommand        : Connect-DblDblServer
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 26
    Line             : Connect-DblServer -ServerInstance 'localhost,1432' -Verbose
    PositionMessage  : At line:1 char:1
                       + Connect-DblServer -ServerInstance 'localhost,1432' -Verbose
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Connect-DblServer
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Line 41 of that cs file for the cmdlet is: ServerConnection srvCn = new ServerConnection();

  • Is there something in my csproj that I have configured wrong?
  • Is this just broken and I need to revert to an older version of the SQLManagementObjects library?

Expected behavior

Runs without exception.

Further technical details

PowerShell 7.2+
Apple Mac M1
Microsoft.Data.SqlClient version: 5.1.1
.NET target: 6.0
Operating system: Windows 11

Additional context
Original issue: microsoft/sqlmanagementobjects#149

Following module is requied:

Install-Module ModuleBuilder # or Install-PSResource ModuleBuilder
./build.ps1 -Verbose

Activity

  1. moved this from To triage to Needs Response in SqlClient Boardon Jan 12, 2026
  2. added
    Repro Available ✔️
    on Jan 12, 2026
  3. moved this from Needs Response to Done in SqlClient Boardon Apr 1, 2026
  4. Frulfump commented on Apr 3, 2026

    @Frulfump

    @mdaigle This was closed as not planned without a comment so no idea why

  5. reopened this on Apr 3, 2026
  6. mdaigle commented on Apr 3, 2026

    @mdaigle
    Contributor

    Apologies, meant to link it to an outstanding powershell interop issue,

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

Metadata

Metadata

Assignees

Labels

Repro Available ✔️

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions