“There was an error running the selected code gene

2019-01-03 17:10发布

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.

21条回答
倾城 Initia
2楼-- · 2019-01-03 17:28

I had the same problem when in my MVC app EF reference property (in Properties window) "Specific version" was marked as False and in my other project (containing DBContext and models) which was refrenced from MVC app that EF reference property was marked as True. When I marked it as False everything was fine.

查看更多
乱世女痞
3楼-- · 2019-01-03 17:29
  • vs2013 update 4
  • ef 5.0.0
  • ibm db2connector 10.5 fp 5

change the web.config file as such: removed the provider/s from ef tag:

<entityFramework>
</entityFramework>

added connection string tags under config sections:

</configSections>
<connectionStrings>
<add name=".." connectionString="..." providerName="System.Data.EntityClient" />
</connectionStrings>
查看更多
趁早两清
4楼-- · 2019-01-03 17:31

I have the exact same problem. First encountered this while following along the Pluralsight Course "Parent-Child Data with EF, MVC, Knockout, Ajax, and Validation".

I am using MVC 5, EF 6.1.1 and framework 4.5.2.

Even after updating my VS2013 to update 4, this error still persisted.

Was able to circumvent this annoying problem by changing the DbSet to IDbSet inside the DbContext class. Answer was originally from here.

//From
public DbSet SalesOrders { get; set; }

//To
public IDbSet SalesOrders { get; set; }
查看更多
混吃等死
5楼-- · 2019-01-03 17:33

What worked for me to resolve this: Close Solution, And open the project by clicking project file and not the solution file, add your controller, and bobs your uncle

查看更多
干净又极端
6楼-- · 2019-01-03 17:33

In case it helps anyone, I renamed the namespace that the model resided in, then rebuilt the project, then renamed it back again, and rebuilt, and then it worked.

查看更多
疯言疯语
7楼-- · 2019-01-03 17:36

None of the above helped for me.

I found that the cause of my problem was overriding OnModelCreating in my context class that the scaffold item was dependent on. By commenting out this method, then the scaffolding works.

I do wish Microsoft would release less buggy code.

查看更多
登录 后发表回答