问题描述
我在 VS 2013 Professional 中创建了一个 MVC 5 应用程序,然后首先将 EF 6.1 代码与 SQL Server Express 上的现有数据库一起使用.当我尝试创建视图时,我使用的是New scaffolded item...",然后选择MVC 5 controller with views, using Entity Framework".我选择模型和上下文类,然后单击确定.然后出现以下错误消息并且没有创建代码.我卸载 EF Power Tools 时出现同样的错误.
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.
错误
运行选定的代码生成器时出错:‘Exception has被调用的目标抛出.'
There was an error running the selected code generator: ‘Exception has been thrown by the target of an invocation.’
我还尝试卸载/重新安装 VS 2013 和 SQL Server,但没有任何更改.
I've also tried uninstalling/reinstalling VS 2013 and SQL Server with no changes.
关于可能导致此错误的任何其他想法?
Any other ideas about what might cause this error?
推荐答案
我也有这个问题,我通过在我的数据库上下文中调用 base.onModelCreating 解决了这个问题
I had this problem too, I solved the problem by calling the base.onModelCreating in my DB context
base.OnModelCreating(modelBuilder);
这篇关于应用程序无法搭建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!