MvcBuildViews true 与 ASP.NET MVC 2 中的实体框架
在 VS 2010 中,如果您使用的是实体框架,则更改 MVC2 项目的 .csproj 文件中的
会导致错误。
无法加载类型“System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider”。 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 129
我想在调试时构建视图,并且我还希望我的项目能够编译!
In VS 2010, changing <MvcBuildViews>true</MvcBuildViews>
in a MVC2 project's .csproj file causes an error if you are using Entity Framework.
Could not load type 'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 129
I want to build views while I'm debugging, and I also want my project to compile!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以通过将以下元素添加到 web.config 文件来解决此 MVC 编译问题:
这将告诉编译器在哪里可以找到缺少的类型。
You can resolve this MVC compile issue by adding the following element to your web.config file:
This will tell the compiler where to find that missing type.
我也遇到了这个问题,并发现我创建了一些实体文件(edmx 等)但已删除它们。
这个问题是在我创建这些文件后才开始发生的。在检查应用程序文件夹时,我发现 Visual Studio 实际上并没有将它们从驱动器中“删除”,它只是将它们从项目中“删除”了。因此,当项目被编译时,它看到了这个 edmx 文件并决定将其包含在内。因此出现错误。
简单修复 - 从驱动器上永久删除实体文件!
i had this problem too, and figured out that i had created some entity files (edmx and the like) but had deleted them.
this problem only started happening after i had created these files. on inspection of the application folders, i found that visual studio hadn't actually 'deleted' them off the drive, it had just 'deleted' them out of the project. therefore, when the project was being compiled, it saw this edmx file and decided it would include it. hence the error.
easy fix - permanently delete the entity files off the drive!
或者,您可以删除构建提供程序。
Alternately you can remove the build provider.
这是一个完整的 web.config 示例
This is an complete example web.config
我在设置
MvcBuildViews="true"
时遇到了类似的错误,这与由于构建临时文件而发现多个 web.configs 的构建有关,并且根本不喜欢它。这是一个完全不同的错误,但我偷偷怀疑它们可能相关...
您可以找到我的原始问题 此处,然后概述解决方案此处。
该解决方案基本上让您更改构建的输出路径...因此您需要将
添加到网站的 csproj 文件中。例如
HTH,
查尔斯
I had a similar error when setting
MvcBuildViews="true"
which had to do with the build finding multiple web.configs due to build temp files and simply not liking it.It's a totally different error, but I have a sneaky suspicion that they could be related...
You can find the original question I had here and then the solution outlined here.
The solution basically gets you to change where the output path is for you builds... so you need to add
<BaseIntermediateOutputPath>
to your website's csproj file.E.g.
HTHs,
Charles
没有足够的代表来添加评论。想要提及的是,您需要将“System.Data.Entity.Design”程序集引用添加到根 Web.config。我无意中尝试将其添加到我的 Views 目录中的 Web.config 中。小心这个陷阱。
Not enough rep to add a comment. Wanted to mention that you need to add the 'System.Data.Entity.Design' assembly reference to the root Web.config. I was inadvertently trying to add it to a Web.config in my Views directory. Watch out for this pitfall.