efcore: .NET Core CLI commands fail when wrong imports were used for first run of dotnet-restore
Updated my Visual Studio with RC 2 and created a Web API project.
Followed documentation guidelines for new application with existing database.
The following error was thrown hitting Scaffold-DbContext.
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. File name: 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at Microsoft.DotNet.ProjectModel.ProjectReader.ReadProject(Stream stream, String projectName, String projectPath, ProjectReaderSettings settings)
at Microsoft.DotNet.ProjectModel.ProjectReader.GetProject(String projectPath, ProjectReaderSettings settings)
at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Got a similiar Newtonsoft related error using CLI dotnet ef
.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (11 by maintainers)
@mhenderson442 thanks for that. I suspect this is related to imports. Try this to fix it
%USERPROFILE%\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools
and%USERPROFILE%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools
. (cref https://github.com/dotnet/cli/issues/2978)Preview 1
Preview 2
cref https://docs.efproject.net/en/latest/miscellaneous/cli/dotnet.html 3. Re run
dotnet restore
and look in the output for errors. VS will trigger this automatically when you save project.json and spits output to “Output > Package Manager”. 4. If commands still fail, can you share the files in%USERPROFILE%\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools
?@ole1986 as the issue describes, your imports are incorrect. For preview1, use “portable-net451+win8” See https://github.com/aspnet/EntityFramework/issues/5458#issuecomment-221912806