I have updated to Visual Studio 2013 update 2 and now I cannot scaffold controllers.
The problem is not project specific: when I try to scaffold
This can be useful for people who haven't installed any scaffolding nuget packages in their solution.
In fact I don't have mvcscaffolding or t4scaffolding installed and got the same error message.
In my case the problem/bug was caused by changing the connection string.
Here what I had/steps to reproduce.
Edited connection string to connect to a real server, like this:
Then I enabled migrations via nuget, like this:
Then I created a controller by using the scaffolding option:
Then I decided to do more code first changes and begin from scratch:
I changed the connection string as follows, to use localdb:
Then I went on:
There was an error running the selected code generator: 'Exception has been thrown by the target of an invocation.'
SOLUTION:
After some investigation, what I did, is changing back the connection string in the web.config to the initial one to the "real server" (instead of localdb). I tried again to generate the controller with views. It worked!
So it seems to me a connection string problem/bug or a localdb problem... can't explain it. Maybe Visual Studio doesn't like what I did, I had to keep my old connection string...
Anyway, so now when I need scaffolding I just change the connection string to the one that works. Then to test my website I change it back to the localdb one.