-
Notifications
You must be signed in to change notification settings - Fork 291
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
System.PlatformNotSupportedException: 'System.Data.SqlClient is not supported on this platform.' #289
Comments
Use Microsoft.Data.SqlClient instead? |
@ErikEJ tried that as well having same issue |
How are you referencing and loading SqlClient? Here's some more info: |
I'm having a similar problem. I have a project that references Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools, both v3.0.0 of these packages. The project is a .NET Standard v2.1 project. An ASP.NET Core v3.0 Web API project that I made references the above project and is able to communicate to the database without any problems. I'm now trying to create an Azure Function using .NET Core v3.0 using the beta runtime. I now receive the error Microsoft.Data.SqlClient is not supported on this platform. I've looked at various solutions for this problem but none seem to be working (Azure/Azure-Functions#1370). Does anyone have any suggestions on this? I'm guessing it's all due to using the preview version in the Azure Function. Project: Azure Function Thanks |
@huwparry22 Can you have a quick try and try to use System.Data.SqlClient 4.7? If you also get the |
Hi @yukiwongky - The error is coming from Microsoft.Data.SqlClient (v1.0.19249.1), which is a dependency of Microsoft.EntityFrameworkCore.SqlServer. As such I don't think I'm able to switch out and use System.Data,SqlClient on it's own. I've tried adding the package and running again but I'm still getting the same error. |
@huwparry22 you've probably already tried this, but just to make sure have you tried the workaround mentioned in #227?
After your azure function is built, can you run |
Upgrading the SQLClient in NuGet from v1.x to Microsoft.EntityFrameworkCore.SqlServer v3.1.0-preview3.19554.8 with dotnetcore 3.1-preview3 fixed this for me. |
That seems to be related to EntityFramework Core 3.0 and 3.0.1 not supporting .NET Standard 2.0 which is back in v3.1.0-preview3. |
We are using EntityFramework Core 2.2.6 |
Could you also try with .NET Core 3.1-preview3, I'm not sure if .NET Core SDK has a role to play too. |
This is an Azure Function app. It's currently only available for netcoreapp2.1. Any preview packages are also not an option for us. We are evaluating Azure Functions, .Net Core for a large enterprise project |
I got it working with .NET Core 3.1, also uploaded example to verify: |
The suggested solution is using the preview Azure Functions SDK. The company's corporate policies do not allow using any preview packages or preview Azure offerings. This was mentioned earlier. |
Getting this error after creating a fresh Azure Function v3 app with Visual Studio Enterprise 2019 Preview Version 16.4.0 Preview 6.0. Actually had the same error when using Microsoft.Data.SqlClient and System.Data.SqlClient. Project Config is as follows
|
Hi @Robzilla
I was able to work with v3-preview using the same repro, updated branch af-v3. Can you post your error so we can take a look?
Yes, that's right. The problem is with "Microsoft.NET.Sdk.Functions" NuGet package v1.0.29, which is the Azure Functions SDK. Updating to 1.0.30-beta4 or 3.0.0-preview2 solves the error, but since you have limitation to use Stable versions only, you'd have to wait till 1.0.30 or 3.0.0 stable versions are released. There's nothing on the SqlClient library that needs to be done. |
So I am zip deploying using VS2019 to Azure and then doing a remote debug session. Also I tried to target Core 3.1 but this dies when trying to publish to Azure. I am guessing 3.1 isn't supported yet but I didn't go down that rabbit hole as I was trying to get a SQL Connection using Core 3.0. Exception Type: System.Exception (System.PlatformNotSupportedException |
Hi @Robzilla I figured out we also need to update the below property in .vscode/settings.json file: I'm wondering if you can modify |
I've created branches 'af-v1' and 'af-v3' in Azure Functions SqlClient Example for testing with respective azure function versions, while 'master' branch demonstrates using v2 version. Summarizing important points here:
Closing the issue as it's not a SqlClient library issue. I've also updated a Dapper Unit of Work example for reference and no issues were found. |
Actually I am running this in Azure not locally. And currently it is the Azure deploy that is throwing the exception. Just because something runs locally doesn't mean everything is ok. Did you manage to get this running in Azure? |
Great do you have a repo I can clone to try? |
Hi @Robzilla You can work with Azure Functions Example linked here: #289 (comment) |
Ok so after some trial and error I am a bit closer to a figuring out what is going on but I need some help with this. I was able to get the simple example running. But when I added a project reference to a .net Core 3.0 class library using the exact same nuget libs as the example I then get a platform not supported exception. If I back out this change then I still get the platform not supported exception.
|
Try removing Otherwise let me know your csproj file structure, I can take a look too. |
I removed the bin and obj folders but the error still occurs every time (at least it is consistent). local.settings.json
Proj file
Debug output
|
Can you provide output of Also try upgrading if not upgraded to latest. |
ok version info below
|
Also tried the latest runtime but same exception. See the proj file below
|
Hi @cheenamalhotra has this problem been allocated to the too hard basket? If so please let me know and I will roll back to core 2.2 and use the older library. |
Hi @Robzilla I'm unable to reproduce any issues at my end so can't really suggest anything, I don't see this could be driver issue as even you did got it working, its just subsequent publishes seem to contradict at your end. Would recommend checking with Azure Functions Teams if they could help figure out problems with caching. Also try not to use |
Is that even an option if I have a dependency on Entity Framework 6.4, which has a dependency on System.Data.SqlClient? I don't see how I can swap in Microsoft.Data.SqlClient- is that possible? |
I upgraded the project to .NET Core 3.1 and managed to get this working too. No problems with the recent versions. Thanks for helping! |
You'd need to update to a newer version of EF that supports Microsoft.Data.SqlClient in order to work with it. Swapping is not possible if EF 6.4 library does not directly reference M.D.S. |
Guys, I was experiencing this same issue. I got it fixed when I updated: I had previously installed: |
Check out dotnet/runtime#28416 (comment) |
Am using Dapper with UnityOfWork with .NetCore 3.0 for passing connection from Startup.cs. Its really frustrating because its working with other PC's not with mine PC. Is there any changes I need to make to my PC?
Below are the dependencies and dotnet --info
Packages
dotnet --info
The text was updated successfully, but these errors were encountered: