Reputation: 788
I'm currently using VS2017 for developing .NET Core MVC Web
When I tried to create a new Controller from Add > Controller, I got this error
Error
There was an error running the code generator: "The specified deps.json
[C:\Users\xxx\Documents\Visual Studio 2017\Projects\bin\MCD\Debug\netcoreapp1.1
\[project name].deps.json] does not exist"
When I explored the solution folder, I found that there are two folder in the bin directory, Debug
and MCD
.
bin
|
- Debug
- netcoreapp1.1
- ...
- [project name].deps.json
|
- MCD <- this is where the scaffolding looks for deps.json
I noticed that I also got the same problem when debugging .NET Console app (which I created from dotnet new console
cli command) from Visual Studio Code. The same problem faced in .deps.json could not be found
Are there any .NET Core configs that I missed? Or this is a bug in .NET Core? I remember I didn't configure anything prior from installing my .NET Core in VS2017
Upvotes: 19
Views: 37926
Reputation: 160
I ran into the same issue in VS 2022 with a Blazor WASM and API project, and found this SO entry in my Google search. I tried a few of the suggestions in this thread to no avail. However, a comment made by FrqSalah about restarting VS was the answer for me, combined with setting the appropriate start up project(s).
Right Click solution --> Properties --> Set appropriate start up project(s) --> Clean --> Rebuild Solution --> Restart VS.
I was able to add a migration and update the database after following the above steps.
Upvotes: 1
Reputation: 97
If you are trying to scaffold in other project which is not your startup project then try setting the project where you want to scaffold as your default startup project. This worked for me.
Upvotes: 1
Reputation: 53
If nothing works try this:
Set the project that contains the entities that you wish to create in the database as the default project.
The case could be that you are trying to add a migration on a project that does not have the required entity objects.
Upvotes: 1
Reputation: 563
I got the same error working with VS 2022 when trying scaffolding my MSSQL database to blazor app from Package Manager Console. It was resolving using the same order from CMD after shifting to the project directory.
Upvotes: 0
Reputation: 205
I was having the same issue with a Blazor WASM
project, but the fix was to set the Server-Project
as the start up project which can be done by right clicking the project in Visual Studio and then running the Command Update-Database
Upvotes: 7
Reputation: 67
I got the same error in visual studio 2019. I cleaned and rebuild the solution and the problem was resolved. I have an HP machine.
Upvotes: 2
Reputation: 490
I had the problem with EF/add-migration in VS Comunity 16.9.3. My start project (bold in solution explorer) was set to one without EF. I switched that to the EF project and add-migration worked fine.
Upvotes: 8
Reputation: 51
Upvotes: 2
Reputation: 7498
In my case, this error appeared after the VS update. Don't know why, but what I did:
bin
and obj
folders.Perhaps it will help someone.
Upvotes: 18
Reputation: 41
Also you can change the launch.json
by adding the MCD folder to the string of the "program"
argument
Upvotes: 0
Reputation: 1155
The file VS 2017 is looking for in
[C:\Users\xxx\Documents\Visual Studio 2017\Projects\bin\MCD\Debug\netcoreapp1.1 [project name].deps.json]
seems to be found at
[C:\Users\xxx\Documents\Visual Studio 2017\Projects\bin\Debug\netcoreapp1.1 [project name].deps.json]
So I just copied the content from the second folder to the first and it worked. No need to change environment variables
Upvotes: 2
Reputation: 482
I did have the same problem under VS2017. My solution was to delete the variable Platform in Environment Variables. Also your must reboot your VS2017.
Upvotes: 0
Reputation: 788
Found the answer here : https://github.com/dotnet/coreclr/issues/113
Apparently, this is some kind of bug that appeared on HP computers. I'll quote from the GitHub issue :
they have an environment variable called Platform, set to MCD which is why you are seeing this error.
This cause .NET Core to look for the file at MCD folder of your bin
, instead of your normal Debug
file. All you have to do is delete the variable or set it to nothing
Upvotes: 14