I just updated System.Data.SqlClient from 4.5.1 to 4.6 (not preview) and got the same error message as described here https://github.com/dotnet/corefx/issues/33620.
Provide the steps required to reproduce the problem
create any project with a dependency on System.Data.SqlClient version 4.6.0
Try to run it on Azure Functions
It should not fail.
Throwing PlatformNotSupportedException.
Downgrading to 4.5.1 works.
There seems some problem when it comes to references related to runtime assemblies, check this issue.
Right click on Function project and Edit <FunctionAppName>.csproj, add items below to copy related assemblies to output dir.
<!-- For publish -->
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- For local debug -->
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
Possibly. I don't need 4.6.0 so I will stick to 4.5.1 for the time being. Just wanted to report the issue to make sure someone knows about it :)
@JohnReeson : Thanks for the possible workaround. But it's not working over here ?
Since we are using Microsoft.EntityFrameworkCore.SqlServer 2.2.0, a downgrade to 4.5.1 is not possible.
Any idea on when this could be fixed ?
Same for me. Working with Microsoft.EntityFrameworkCore.SqlServer 2.2.0 and get:
System.Private.CoreLib: One or more errors occurred. (System.Data.SqlClient is not supported on this platform.)
Same here
Can confirm that the issue still exists in (preview) versions beyond 4.6.0.
And... also important to note... that @JohnReeson 's workaround does work.


(The error is a good sign... as the error occured before actually being able to get a connection error) :)
This workaround is still working locally, but it does not work on Azure Devops anymore. Last time I did a build was December 2018. Yesterday (3/5/2019) The build failed to find the dll in the user nuget path on the build host:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4582,5): Error MSB3030: Could not copy the file "C:\Users\VssAdministrator\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll" because it was not found.
Process 'msbuild.exe' exited with code '1'.
Is it in another folder?
I'm having this issue with 4.7.0 preview.
Most helpful comment
There seems some problem when it comes to references related to runtime assemblies, check this issue.
Right click on Function project and
Edit <FunctionAppName>.csproj, add items below to copy related assemblies to output dir.