简体   繁体   English

.NET Core NuGet EF Core 版本不匹配

[英].NET Core NuGet EF Core Version doesn't match

I am following this tutorial: Tutorial我正在学习本教程: 教程

I searched for about 4 hours and didn't find a solution for how to fix this error:我搜索了大约 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.启动项目“DatabaseConnection”是 Visual Studio 2015 的 ASP.NET Core 或 .NET Core 项目。此版本的 Entity Framework Core 包管理器控制台工具不支持这些类型的项目。

I produced it with following command:我使用以下命令生成它:

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

Following I tried to update the EF SQL server.接下来我尝试更新 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.json GET 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 143ms Error 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'.获取 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') OK 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”的包元数据时出错“微软和.NET”。 A task was canceled.任务已取消。 Retrieving package 'Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final' from 'nuget.org'.从“nuget.org”检索包“Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final”。 Installing NuGet package Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final.安装 NuGet 包 Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final。 Successfully installed 'Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final' to DatabaseConnection Executing nuget actions took 122.12 ms Time Elapsed: 00:00:00.9439736已成功将“Microsoft.EntityFrameworkCore.Tools 1.1.0-msbuild3-final”安装到 DatabaseConnection 执行 nuget 操作花费了 122.12 毫秒时间:00:00:00.9439736

But with this error the Package isn't updated.但是由于这个错误,包没有更新。

The following is my project.json file:以下是我的 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":{

    }
}}

My dotnet information:我的网络信息:

PM> dotnet --info PM> dotnet --info

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

Product Information:产品信息:

Version: 1.0.0-preview2-1-003155版本:1.0.0-preview2-1-003155

Commit SHA-1 hash: d7b0190bd4提交 SHA-1 哈希:d7b0190bd4

Runtime Environment:运行环境:

OS Name: Windows操作系统名称:Windows

OS Version: 10.0.14393操作系统版本:10.0.14393

OS Platform: Windows操作系统平台:Windows

RID: win10-x64摆脱:win10-x64

What am I supposed to do?我应该做些什么?

I had a similar error trying to create a data migration for a code first project using Visual Studio 2015.Netcore data project:我在尝试使用 Visual Studio 2015.Netcore 数据项目为代码优先项目创建数据迁移时遇到了类似的错误:

"Startup project 'Company.Application.Data' 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." “启动项目‘Company.Application.Data’是 Visual Studio 2015 的 ASP.NET Core 或 .NET Core 项目。此版本的 Entity Framework Core 包管理器控制台工具不支持这些类型的项目。”

Solved using following steps using PowerShell:使用 PowerShell 使用以下步骤解决:

  1. Navigate to the project directory(in my case f:_dev\Company.Application.Data)导航到项目目录(在我的例子中是 f:_dev\Company.Application.Data)
  2. type: dotnet restore类型: dotnet 还原
  3. Add new migration example type: dotnet ef migrations add MyExampleMigrationName添加新的迁移示例类型: dotnet ef migrations add MyExampleMigrationName
  4. Your migration should appear in visual studio您的迁移应该出现在 visual studio 中
  5. Edit your new migration as needed根据需要编辑您的新迁移

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM