首页 文章

.NET Core NuGet EF核心版本不匹配

提问于
浏览
4

首先,我遵循这个教程:Tutorial

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

启动项目“DatabaseConnection”是Visual Studio 2015的ASP.NET核心或.NET核心项目 . 此版本的Entity Framework核心软件包管理器控制台工具不支持这些类型的项目 .

我使用以下命令生成它:

Scaffold-DbContext“Server = 127.0.0.1; Database = vicotv; Trusted_Connection = True;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir模型

以下我尝试更新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')确定https://api.nuget . org / v3 / registration1-gz / microsoft.entityframeworkcore.tools / index.json 143ms查找“https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/”存储库时出错:检索时出错来自'Microsoft和.NET'的'Microsoft.EntityFrameworkCore.Tools.1.1.0-msbuild3-final'的包元数据 . 任务被取消了 . 从'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 ms时间耗尽: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

注意:我已经在链接中添加了空格,因为我没有足够的声誉 .

我该怎么做?

1 回答

  • 1

    尝试使用Visual Studio 2015 .Netcore数据项目为代码优先项目创建数据迁移时出现类似错误:

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

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

    • 导航到项目目录(在我的例子中为f:_dev \ Company.Application.Data)

    • 类型: dotnet restore

    • 添加新的迁移示例类型: dotnet ef migrations add MyExampleMigrationName

    • 您的迁移应该出现在visual studio中

    • 根据需要编辑新迁移

相关问题