gpt4 book ai didi

c# - .NET Core NuGet EF Core 版本不匹配

转载 作者:行者123 更新时间:2023-11-30 12:40:18 33 4
gpt4 key购买 nike

我正在学习本教程:Tutorial

我搜索了大约 4 个小时,没有找到解决此错误的方法:

Startup project 'DatabaseConnection' is an ASP.NET Core or .NET Core project for Visual Studio 2015. This version of the Entity Framework Core Package Manager Console Tools doesn't support these types of projects.

我使用以下命令生成它:

Scaffold-DbContext "Server=127.0.0.1;Database=vicotv;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

接下来我尝试更新 EF SQL 服务器。

PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 1.1.0-msbuild3-final

GET https ://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools/index.jsonGET https ://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/Packages(Id='Microsoft.EntityFrameworkCore.Tools',Version='1.1.0-msbuild3-final')OK https ://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools/index.json 143msError finding repository for 'https ://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/': An error occurred while retrieving package metadata for 'Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final' from source 'Microsoft and .NET'.A task was canceled.Retrieving package 'Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final' from 'nuget.org'.Installing NuGet package Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final.Successfully installed 'Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final' to DatabaseConnectionExecuting nuget actions took 122.12 msTime Elapsed: 00:00:00.9439736

但是由于这个错误,包没有更新。

以下是我的project.json文件:

{
"buildOptions":{
"emitEntryPoint":true,
"preserveCompilationContext":true
},
"dependencies":{
"Microsoft.EntityFrameworkCore.SqlServer":"1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design":"1.1.0",
"Microsoft.ApplicationInsights.AspNetCore":"2.0.0",
"Microsoft.AspNetCore.Mvc":"1.1.1",
"Microsoft.AspNetCore.Routing":"1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration":"1.1.0",
"Microsoft.AspNetCore.Server.Kestrel":"1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables":"1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions":"1.1.0",
"Microsoft.Extensions.Configuration.Json":"1.1.0",
"Microsoft.Extensions.Logging":"1.1.0",
"Microsoft.Extensions.Logging.Console":"1.1.0",
"Microsoft.Extensions.Logging.Debug":"1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions":"1.1.0",
"Microsoft.NETCore.App":"1.1.0",
"Microsoft.EntityFrameworkCore.Design":"1.1.0",
"Microsoft.EntityFrameworkCore":"1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools":"1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools":"1.1.0-msbuild3-final"
},
"frameworks":{
"netcoreapp1.0":{
"imports":[
"dotnet5.6",
"portable-net45+win8"
]
}
},
"publishOptions":{
"include":[
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"runtimeOptions":{
"configProperties":{
"System.GC.Server":true
}
},
"scripts":{
"postpublish":[
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
},
"tools":{

},
"runtimes":{
"win10-x86":{

},
"win10-x64":{

}
}}

我的 dotnet 信息:

PM> dotnet --info

.NET 命令行工具 (1.0.0-preview2-1-003155)

产品信息:

版本:1.0.0-preview2-1-003155

提交 SHA-1 哈希:d7b0190bd4

运行时环境:

操作系统名称:Windows

操作系统版本:10.0.14393

操作系统平台:Windows

RID:win10-x64

我该怎么办?

最佳答案

我在尝试使用 Visual Studio 2015 .Netcore 数据项目为代码优先项目创建数据迁移时遇到了类似的错误:

“启动项目‘Company.Application.Data’是 Visual Studio 2015 的 ASP.NET Core 或 .NET Core 项目。此版本的 Entity Framework Core 包管理器控制台工具不支持这些类型的项目。”

使用 PowerShell 通过以下步骤解决:

  1. 导航到项目目录(在我的例子中是 f:_dev\Company.Application.Data)
  2. 类型:dotnet 恢复
  3. 添加新的迁移示例类型:dotnet ef migrations add MyExampleMigrationName
  4. 您的迁移应该出现在 visual studio 中
  5. 根据需要编辑您的新迁移

关于c# - .NET Core NuGet EF Core 版本不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207992/

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