【问题标题】:Nuget package for mysql .net5用于 mysql .net5 的 Nuget 包
【发布时间】:2021-10-08 13:26:58
【问题描述】:

我只是想使用可以连接到 MySQL 数据库(在容器中运行)的 .NET 核心控制台应用程序创建一个 hello world。

当我尝试使用 Nuget 包时:

dotnet add package MySql.Data --version 8.0.26

它对我不起作用,我遇到了错误。我相信这应该支持.NET core 5,不知道如何检查.NET core 是否支持以及什么版本。 有人可以帮我理解我在这里缺少什么吗?

PS C:\coding\c#\helloworld> cd .\sampleapp\
PS C:\coding\c#\helloworld\sampleapp> dotnet add package MySql.Data --version 8.0.26
  Determining projects to restore...
  Writing C:\Users\manish\AppData\Local\Temp\tmp2756.tmp
info : Adding PackageReference for package 'MySql.Data' into project 'C:\coding\c#\helloworld\sampleapp\sampleapp.csproj'.
info : Restoring packages for C:\coding\c#\helloworld\sampleapp\sampleapp.csproj...
error: NU1100: Unable to resolve 'MySql.Data (>= 8.0.26)' for 'net5.0'.
  Determining projects to restore...
info : Adding PackageReference for package 'MySQL.Data' into project 'C:\coding\c#\helloworld\sampleapp\sampleapp.csproj'.
error: There are no versions available for the package 'MySQL.Data'.

【问题讨论】:

  • 这并不能直接回答您的问题,但我建议使用MySqlConnector 并抛弃MySQl.Data。有几个原因它的表现出色并且一直是异步的!
  • 感谢@rippo 的建议,让我试一试,是 MySqlConnector,mariadb 也一样吗?
  • 是的,伙计,这就是我用它的目的!
  • MySql.Data 8.0.26 显示 on NuGet.org 它支持 .NET 5
  • 我想知道您的 NuGet 源是否配置不正确,因为 MySql.Data 确实支持 net5.0。但是,像@Rippo 我强烈推荐 MySqlConnector。

标签: c# mysql asp.net .net .net-core


【解决方案1】:

在这篇文章中找到了解决方案

error: NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'

我需要删除这个目录才能让它工作

C:\Users\AppData\Roaming\NuGet

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 2021-10-18
    相关资源
    最近更新 更多