MVC3 添加控制器上下文/模型位置
在我的 VS MVC 项目中,出于脚手架的目的,“添加控制器”对话框为我提供了当前项目中潜在的数据库上下文和模型的列表。但是,如果我在单独的项目中有模型和上下文怎么办?如何配置 Visual Studio 以在扩展位置进行搜索?
显然其他人能够从“添加控制器”中看到所有潜在的上下文和模型“对话。我不知道为什么我不能。
In my VS MVC project, for scaffolding purposes, the "Add Controller" dialogue offers me a list of potential db contexts and models from the current project. But what if I have models and contexts in a seperate project? How do I configure Visual Studio to search in extended locations?
Evidently others are able to see all potential contexts and models from the "Add Controller" dialogue. I don't know why I can't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为,您应该在具有控制器的项目的引用部分中添加具有模型和上下文的项目。
参考 -> 添加参考,然后浏览模型和上下文的项目。
另外,您应该将这些项目放在同一个解决方案中,以便该参考工作,并且您应该在主要项目之前在参考部分中构建项目。
I think, you should add the project that has models and contexts in References part of the project that has controller.
References->Add Reference then browse for the project of models and contexts.
Also , you should put these projects in the same solution for this reference to work and you should build project in reference part before main one .
发现问题了!在我的解决方案中,我的 MVC 项目引用 EF 4.1 程序集 - 而我的支持 EF 项目引用 EF 4.2 程序集。当我升级到 4.2 时它们都匹配时,最后“添加控制器”对话框向我显示了两个项目的所有类!
Found the problem! In my solution, my MVC project was referencing the EF 4.1 assembly - while my supporting EF project was referencing an EF 4.2 assembly. When I upgraded to have both of them match at 4.2, finally the "add controller" dialogue showed me all classes from both projects!