Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Data.SqlClient is not supported on this platform - Entity Framework Core 3.1

I'm using Microsoft.EntityFrameworkCore.SqlServer (3.1) in a .NET Core 3.1 library. This library gets loaded at runtime by an executable .NET Core project by using:

Assembly.LoadFrom('some.dll');

When trying to retrieve data from a DbSet, I get the following exception:

System.PlatformNotSupportedException: 'Microsoft.Data.SqlClient is not supported on this platform.'

I guess it has something to do with loading the library at runtime, but I don't get why?

I tried various different things, like overriding the Microsoft.Data.SqlClient library with Version 1.1 or 2.0, but without any success.

like image 500
Jonas Hammerschmidt Avatar asked Jun 22 '20 12:06

Jonas Hammerschmidt


People also ask

Does Entity Framework use SqlClient?

The SqlClient provider for the Entity Framework provides mapping information between conceptual model types and SQL Server types.

Where is Microsoft Data SqlClient?

The Microsoft. Data. SqlClient API details can be found in the . NET API Browser.

What is data SqlClient?

SqlClient) Provides a simple way to create and manage the contents of connection strings used by the SqlConnection class.

What is Microsoft Data SqlClient SNI?

dotnet/SqlClient. Microsoft. Data. SqlClient provides database connectivity to SQL Server for . NET applications.


1 Answers

I received this message: System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.

My solution:

  • Add the latest version of Microsoft.Data.SqlClient as a NuGet dependency (Current v.2.1.2)
  • If you are using the Newtonsoft namespace, e.g. Newtonsoft.Json and this namespace could not be found after installing Microsoft.Data.SqlClient, then get the Newtonsoft.Json dependency from NuGet.
like image 198
Mats Gausdal Avatar answered Nov 14 '22 23:11

Mats Gausdal