"The expected lock file doesn't exist. Please run "dnu restore"" right after I have done so "The expected lock file doesn't exist. Please run "dnu restore"" right after I have done so json json

"The expected lock file doesn't exist. Please run "dnu restore"" right after I have done so


I faced the same problem, and fixed it by:- Right click on "References"- Select "Restore Packages"

Or Ctrl + Shilf + R

It will create/update the "project.lock.json" file, which includes a complete list of all of the NuGet packages the app is using. In my opinion, you shouldn't put it in the source control


Try this:

Close Visual Studio completely.

Open a Visual Studio Command Prompt window.

cd C:\XXX\XXX\src\XXX\dnu restorednx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer


If you are running this command on an application currently executing in a Windows Server Kernel environment, Core 5.0 will not work often. It can read some, but not create, especially if you host in IIS. I had this issue a lot, I found it best to just skip EntityFramework.Commands in main dependency, and jump down to

"frameworks":{    "dnx451":{          "dependencies":{                 "EntityFramework.Commands":"7.0.0-beta7"          }      }  ,"dnxcore50"...

also, make sure when you get ready to run dnx, run

dnvm use latest -r clr -arch {your server kernel arch} x64|x86

to ensure you are not trying to invoke coreclr for commands. that should fix the issue, and it has for me on a production server (because scaffolding the dbcontext is largely harmless)