There was an error generating …DbContext… Try rebuilding your project?

Whilst working on a development, I encountered the above error when trying to scaffold up a Web API Controller. Nothing had changed that I was aware of so it kinda threw me for a while.

I’d previously done ~20 controllers without a problem over a period of time, and any errors that I got were quickly sorted with a rebuild. But this time, the error wouldn’t go away.

FIX:

All of the suggested solutions I found by Googling didn’t work, but I eventually fixed it by updating the Entity Framework Packages from Nuget.

Actually, I updated all of my packages but the assumption is that the Entity Framework update fixed it.

Hope this helps someone!

:)