Application can't scaffold items

asp.net-mvc asp.net-mvc-scaffolding c# entity-framework-6 sql

Question

I created an MVC 5 application in VS 2013 Professional and then used EF 6.1 code first with an existing DB on SQL Server Express. When I try to create the views I’m using the “New scaffolded item…” then selecting the “MVC 5 controller with views, using Entity Framework.” I select the model and context classes and click OK. Then the following error message appears and no code is created. I’ve uninstalled EF Power Tools with the same error.

Error

There was an error running the selected code generator: ‘Exception has been thrown by the target of an invocation.’

I've also tried uninstalling/reinstalling VS 2013 and SQL Server with no changes.

Any other ideas about what might cause this error?

1
48
2/19/2016 1:49:05 AM

Accepted Answer

I had this problem too, I solved the problem by calling the base.onModelCreating in my DB context

base.OnModelCreating(modelBuilder);
15
5/28/2014 7:46:39 AM

Popular Answer

In my case I moved my connection strings out of the Web.config to

<connectionStrings configSource="ConnectionStrings.config"/>

that when I started getting the error when I was trying to scaffold.

There was an error running the selected code generator: ‘Exception has been thrown by the target of an invocation.’

Moving my connection strings back to the Web.config solved my issue.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow