I'm creating a new view off of a model.
The error message I am getting is
Error
There was an error running the selected code generator:
'Access to the path
'C:\Users\XXXXXXX\AppData\Local\Temp\SOMEGUID\EntityFramework.dll' is denied'.
I am running VS 2013 as administrator.
I looked at Is MvcScaffolding compatible with VS 2013 RC by command line? but this didn't seem to resolve the issue.
VS2013 C#5 MVC5 Brand new project started in VS 2013.
This is typically caused by an invalid
Web.config
file. I had the same problem and it turned out I inadvertently changed the HTML comment block<!-- -->
to a server side comment block@* *@
(through a Replace All action).And in case you are developing a WinForms application, try to look to
App.config
.For us it has something to do with build configurations, where we have a Debug|x64 build configuration that we had recently switched to using, which in retrospect seemed to be when the scaffolding stopped working.
(I suspect that there are at least 10 different things that can cause this, as evidenced by the various answers on SO that some people find to work for them--but which don't work for others, so I'm not suggesting my solution will work for everyone).
What worked for us (using VS 2013 Express for Web on 64 bit Windows 7):
It (scaffolding) was NOT working in Debug|x64 Build configuration. But doing the following (and it seems like every step is necessary--couldn't figure out how to do it in a more streamlined way) seems to work for us.
If you need to switch back to a scaffolding-non-working build configuration, you can do so, after you've scaffolded everything you need to for the moment. We switched back to our Debug|x64 after scaffolding what we needed to.
I have seen this error with a new MVC5 project when referencing a model from a different project. Checking the path, EntityFramework.dll did exist. It was read-only though. Process monitor showed that there was an error attempting to delete the file. Setting the EntityFramework.dll in my packages folder (copy stored in source control) to writeable got around this error but brought up another one saying that it couldn't load the EntityFramework assembly because it didn't match the one referenced. My model class was defined in a different project that was using an older version of the entity framework. The MVC5 project was referencing EF 6 while the model was from a project references EF 4.4. Upgrading to EF 6 in the model's project fixed it for me.
Rebuild the solution works for me. before rebuild, I find references number of my 'ApplicationDbContext' is zero, that is impossible, so rebuild solution, everything is OK now.
This happened to me when I attempted to create a new scaffold outside of the top level folder for a given Area.
| - File.cs (tried to create a new scaffold here. Failure.)
I simply re-selected my area and the problem went away:
Note that after scaffold generation you are taken to a place where you will not be able to create a new scaffold without re-selecting the area first (in VS 2013 at least).
I tried every answer on every website I found, and nothing worked... until this. Posting late in case anyone like me comes along and has the same frustrating experience as I have.
My issue was similar to many here, generic error message when trying to use scaffolding to try and add a new controller (ef6, webapi). I initially was able to use scaffolding for about 15 controllers, after that it just stopped working one day.
Final Solution:
Voila! (for me)