【发布时间】:2017-02-13 15:44:31
【问题描述】:
我正在关注本教程:Tutorial
我搜索了大约 4 个小时,没有找到解决此错误的方法:
启动项目“DatabaseConnection”是 Visual Studio 2015 的 ASP.NET Core 或 .NET Core 项目。此版本的 Entity Framework Core 包管理器控制台工具不支持这些类型的项目。
我使用以下命令生成它:
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
获取 https://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools/index.json 获取 https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/Packages(Id='Microsoft.EntityFrameworkCore.Tools',Version='1.1.0-msbuild3-final') 好的 https://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools/index.json 143ms 查找“https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/”的存储库时出错:检索“Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final”的包元数据时出错来自源“Microsoft 和 .NET”。 一个任务被取消了。 从“nuget.org”检索包“Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final”。 安装 NuGet 包 Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final。 成功将“Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final”安装到 DatabaseConnection 执行 nuget 操作耗时 122.12 毫秒 经过时间: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 版本是什么,您在项目中使用的 .net 框架版本是什么?
-
@Baro 我正在使用 VisualStudio 2015 Professional 和 .net 框架,我在我的项目中使用的是:.NET Framework 4.5.2 而我的项目是 ASP.Net Core Web Application
-
我不太确定,因为教程链接可能已经过时了。需要一个是 VS 2017,但可能是因为当时它支持 .net Core 而 VS 2015 不支持。但是你的项目使用了 4.5.2 版本的框架似乎很奇怪,Core 版本是 6.x !可能是你的问题?
-
@Baro 你的意思是我应该尝试安装 VS 2017,因为这是 VS 2015 的问题?这将花费大量时间进行安装..
-
尝试在 project.json 中使用
"Microsoft.EntityFrameworkCore.Tools":"1.1.0-preview4-final"而不是 msbuild3,因为您使用的是 project.json(显然不是 VS2017)
标签: c# visual-studio entity-framework .net-core