【发布时间】: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