-
Notifications
You must be signed in to change notification settings - Fork 281
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
Microsoft.Data.SqlClient is not supported on this platform #2030
Comments
I have this issue as well and also had it on .net 6 when running it on Linux. I found a workaround which is to send the runtime identifier. Like this |
Any solutions in windows environment? |
You'd need to find the runtime id for the windows you're using. I found the Linux one somewhere in Microsofts documentation. Sorry that I can't be more specific. Following the same logic as the Linux one it'd be |
Microsoft's documentation that is linked by OP leads to a 404. Great. I have a similar issue. Creating it now and linking to this. I'm on Windows 11. |
Could any one here provide a simple repro of the issue? |
I'll happily do so - just need to create one. Will take a crack at this first thing in the morning. |
Hi @JRahnama , I've created the simplest case I could - https://github.com/SudoCerb/manictime-microsoft.data.sqlclient-min-repro Instructions are in the README.md. I hope that this helps! |
I tried .Net7 ASP.NetCore WebAPP with class library targetting .NET7 on Windows 10. I am not seeing the exception, I am attaching the sample. The steps I followed:
|
Just to add to what I wrote earlier. The link where I found the RID for Linux is here. |
Just wanted to add that I'm getting the same exception when init dbcontext, .net 7 (latest sdk) on Linux mint 21 running in blazer server with a DAL in a separate DLL project. Running the blazer solution on the metal and connecting to a SQL 2022 instance in a container. Exactly the same code works fine on two separate windows 10 enterprise boxes, connecting native and container SQL server 2022 respectively. Repo is opensource here, and reproducible from the PlatformNotSupportedException branch https://github.com/SimonGeering/AdminAssistant/tree/PlatformNotSupportedException I'll try to get the time this week to add repo instructions but give it the config for the SQL server and run an ef migration and boom. Happy to help with testing if any fix can come for this, will also try it with the 8 preview when I get the chance and let you know. |
Detecting the correct target framework is on runtime to be discovered not MDS. Any failed attempts will fall back to the "not supported platform" dll and throw this exception which is by design. |
I think it would be quite useful for the error to say something like that. I have no idea how to get around this but that error message would have been more helpful! |
In my case, I was compiling just fine yesterday; moved to a new account on the same server (also Linux Mint 21) today and even though I'm targetting dotnet6 and have only dotnet 6 runtimes and SDK installed, I'm getting the same. |
On Mint/Ubuntu it seems to be an issue with the Ubuntu versions of Dotnet. I replaced them with the Microsoft packages from https://packages.microsoft.com/ubuntu/22.04/prod and all is now fine. [Instructions at https://learn.microsoft.com/en-ca/dotnet/core/install/linux-ubuntu#register-the-microsoft-package-repository] |
I'm having this issue as well now. All packages and dotnet SDK on my 20.04 server are up to date. Builds fine locally, but fails on server deploy. Dotnet 7. edit: weird. It doesn't appear the microsoft.data.sqlclient has not been updated between my previous update and my current update - both on 5.1.1................ edit: Setting self contained to false resolved the issue. The post here: #1643 helped with that trouble shooting step. |
For what it's worth I just started having failures on this with a repo that worked two weeks ago. I had to re clone down the repo, made some code changes, and now it doesn't work. Windows 10, net7.0. Setting self contained to false has not helped. edit: Creating a brand new publish profile from scratch and basically not touching it fixed it. But it's identical to the profile that doesn't function. |
Closing it as it's external. Feel free to post in this thread. |
Did someone manage to get this working for Windows? Windows 11, Visual Studio 2022, .NET Standard 2.0 Class Library project |
For Docker DOTNET Alpine I had to set the runtime id to Previously I had only the architecture set to FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
RUN dotnet publish -r linux-musl-x64 "path.to.csproj" -c Release -o /app \
--self-contained true \
/p:PublishSingleFile=false
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS final
ENTRYPOINT ["./entry-point-file"] |
I just don't understand how any one is supposed to develop using Microsoft .net technologies any more. The stuff is so buggy it drives me insane. Yesterday my API was working perfectly accessing stored procs no problems, today first thing it says is: Microsoft.Data.SqlClient is not supported on this platform |
Update: I reverted to yesterdays backup of the API and Client, deployed the API to the win 2016 server and it successfully calls the database strored procs with out this stupid error. As I said the only thing I did was add Token Bearer API security to the API and Client and this error suddenly popped up.. "Microsoft.Data.SqlClient is not supported on this platform" I am going to try repeat these steps and see if it does it again. I hope not! |
Error no longer appears, when I reworked my steps from yesterday's backup thank goodness. Who knows what happened first time.? |
In my case, adding to .csproj file:
managed to make it work. |
I also had this problem when upgrading from .NET 7.0 to .NET 8.0. Adding the nuget package |
I'm running into the same issue for the same reason. I read on a few other forums that downgrading to 5.1.5 helped. But that hasn't worked for me. |
Issue Description
I have an ASP.NET Core MVC project targeting .NET 7 and a library project also targeting .NET 7. After referencing the library project in the MVC project and publishing it, I receive the following error when trying to use the
DbContext
:System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Expected Behavior
I expected to be able to use the
DbContext
without any issues after referencing the .NET 7 library project.Steps to Reproduce
Additional Information
The text was updated successfully, but these errors were encountered: