【问题标题】:Trying to get ef core migrations to work on project migrated to .net core 2试图让 ef 核心迁移工作在迁移到 .net 核心 2 的项目上
【发布时间】:2017-09-06 00:17:11
【问题描述】:

我正在尝试添加我的第一个 EF Core 2 迁移。我为该解决方案运行了 EF6 迁移,但现在我已迁移到 EF Core 2 和 .Net Core 2.0。当我运行这个命令时:

dotnet ef migrations add InitialMigration

我得到了这个例外:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
    at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive)
    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
    at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String contentRootPath, String dataDirectory, String rootNamespace, String environment)
    at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
    at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsListCommand.Execute()
    at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
    at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

我正在 Windows 10 上的 Visual Studio 2017 v15.3 中的包管理器控制台中运行该命令。尝试从 Windows 命令行运行它时,我收到了相同的消息。启动项目以及默认项目设置为包含数据库上下文类的类库。这是项目的 .csproj 项目文件:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Analytics" Version="3.0.0" />
    <PackageReference Include="AWSSDK.Core" Version="3.3.17.6" />
    <PackageReference Include="AWSSDK.S3" Version="3.3.10.2" />
    <PackageReference Include="CoreCompat.System.Drawing.v2" Version="5.2.0-preview1-r131" />
    <PackageReference Include="HtmlAgilityPack" Version="1.5.1" />
    <PackageReference Include="ImageProcessor" Version="2.5.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="2.0.0-preview1-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
    <PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-beta5" />
    <PackageReference Include="QRCoder" Version="1.2.9" />
    <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
    <PackageReference Include="WindowsAzure.Storage" Version="8.4.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
  </ItemGroup>
</Project>

知道我做错了什么或如何解决问题吗?

【问题讨论】:

    标签: c# .net-core entity-framework-core


    【解决方案1】:
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
                            Version="1.0.0" />
    

    您需要更新到版本 2.0.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2020-05-06
      • 1970-01-01
      • 2018-05-15
      • 2022-01-16
      • 2020-02-15
      • 2018-05-21
      相关资源
      最近更新 更多