gpt4 book ai didi

mysql - Ubuntu Linux 上的 dotnet 核心使用 asp.net MVC 和 EF MySQL 错误 NU1001 : cannot restore MySql. Data.EntityFrameworkCore

转载 作者:可可西里 更新时间:2023-11-01 09:01:42 24 4
gpt4 key购买 nike

我构建了一个简单、扁平的 dotnet 核心 MVC 应用程序,我希望它能在 Linux 上运行。它使用 EF 从 mysql 表中提取一些记录并将它们显示在 View 中。这一切都在我的主机 (Win10) 上构建和运行,但不会在我已经启动以进行测试的 Ubuntu VM 中运行

执行“dotnet restore”后,“dotnet build”或“dotnet run”出现以下错误:

Project CoreCrossPlatformFlat (.NETCoreApp,Version=v1.0) will be compiled because the version or bitness of the CLI changed since the last build Compiling CoreCrossPlatformFlat for .NETCoreApp,Version=v1.0 /opt/dotnet/corecrossplatform/src/CoreCrossPlatformFlat/project.json(25,52): error NU1001: The dependency MySql.Data.EntityFrameworkCore >= 7.0.4-IR-191 could not be resolved.

Compilation failed. 0 Warning(s) 1 Error(s)

仅供引用:这是“dotnet --info”报告的内容:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information: Version: 1.0.0-preview2-003121 Commit SHA-1 hash: 1e9d529bc5

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64

对于 VM,我遵循了以下说明:

https://www.microsoft.com/net/core#ubuntu

project.json 看起来像这样:

{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0",
"MySql.Data.Core": "7.0.4-IR-191",
"MySql.Data.EntityFrameworkCore": "7.0.4-IR-191"
},

"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}

如果有帮助,这里是解决方案的压缩包: https://s3.amazonaws.com/kilonova-public/code/CoreCrossPlatformFlat.zip

最佳答案

今天遇到同样的问题。请尝试删除项目文件夹中除 project.json 文件和所有 .cs 文件之外的所有文件和文件夹。然后 dotnet restore 和 dotnet run。这个对我有用。 :)

关于mysql - Ubuntu Linux 上的 dotnet 核心使用 asp.net MVC 和 EF MySQL 错误 NU1001 : cannot restore MySql. Data.EntityFrameworkCore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39330191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com