I\'m using MVC 5 and .net 4.6 to create a web API that my mobile app can connect too.
Whenever I build the project I get hundreds of errors telling me that I need to add
This wasted lot of my time. Close the visual studio. Delete the .vs folder and restart visual studio. Everything should work fine.
Usually this happens when you change branches or merge branches.
VS2019 solution files were placed under the One drive folder, moving to a different folder outside one drive, fixed this.
For me, the problem occurred when I added a new project to my solution. I re-built the solution and the errors went away.
In my case, this is different. First check System.Runtime reference is added to your project or not. If it is added to your project, please follow the below steps.
Note : In my Case I am using Visual Studio 2019 and Project Framework Version - 4.6.2
I'm guessing a bit here but it looks suspicious that you are using the regular System.Data.*
stuff for dnx451
but doesn't have anything to make up for it for dnxcore50
. Are you targeting the core edition as well or is it just leftovers from project creation? If you want to target the core edition and still use the old System.Data.*
stuff you'll need to wrap anything from those assemblies like this.
#if DNX451
// Do some DNX451 specific stuff here
#endif
And the other way around as well.
#if DNXCORE50
// Do some DNXCORE50 specific stuff here
#endif
But if you aren't thinking about supporting this yet I would simply remove dnxcore50
from the framework list and your errors will probably go away.
I run dotnet restore
command on Package manager console and problem solved.