c# - 此平台不支持 Microsoft.Data.SqlClient - Entity Framework Core 3.1

标签 c# .net-core entity-framework-core ef-core-3.1 entity-framework-core-3.1

我正在使用 Microsoft.EntityFrameworkCore.SqlServer (3.1) 在 .NET Core 3.1 库中。这个库在运行时由一个可执行的 .NET Core 项目加载,使用:

Assembly.LoadFrom('some.dll');
尝试从 DbSet 检索数据时,我得到以下异常:

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


我想这与在运行时加载库有关,但我不明白为什么?
我尝试了各种不同的东西,比如覆盖 Microsoft.Data.SqlClient 1.1 或 2.0 版的库,但没有任何成功。

最佳答案

我收到了这条消息:System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform. 我的解决方案:

  • 添加最新版本的 Microsoft.Data.SqlClient 作为 NuGet 依赖项(当前 v.2.1.2)
  • 如果您使用的是 Newtonsoft命名空间,例如安装 Microsoft.Data.SqlClient 后找不到 Newtonsoft.Json 和此命名空间,然后从 NuGet 获取 Newtonsoft.Json 依赖项。
  • 关于c# - 此平台不支持 Microsoft.Data.SqlClient - Entity Framework Core 3.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62514719/

    相关文章:

    c# - ToolStrip 圆角

    c# - Fedora 35 上的 Rider 不会显示 netstandard

    entity-framework - EF Core - 如何在 Entity Framework 核心中启用延迟加载?

    c# - 使用 linq 和 lambda 对列表进行分组和展平

    c# - 反转<>和反转

    c# - 从 AuthenticationHandler 返回自定义对象

    f# - 尽管程序正常运行,类型提供程序 'ProviderImplementation.JsonProvider' 仍报告错误

    c# - Xamarin Forms +Entity Framework Core + SQLite - 在生产中断应用程序上调用迁移

    c# - 获取用户上次访问时间

    c# - 需要有关通过触发器访问的游戏对象刚体的建议