Trying to get ef core migrations to work on project migrated to .net core 2

.net-core c# entity-framework-core

Question

I'm trying to add my first EF Core 2 migration. I had EF6 migrations running for the solution, but now I've migrated to EF Core 2 and .Net Core 2.0. When I run this command:

dotnet ef migrations add InitialMigration

I get this exception:

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.

I'm running the command from the package manager console in Visual Studio 2017 v15.3 on Windows 10. I get the same message when trying to run it from the windows command line. The startup project as well as the default project is set to a class library that contains the database context class. This is the .csproj project file for the project:

<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>

Any idea on what I'm doing wrong or how I can troubleshoot the issue?

1
6
9/4/2017 3:26:28 PM

Accepted Answer

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
                        Version="1.0.0" />

You need to update to version 2.0.0.

4
9/5/2017 4:17:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow