MVC3 添加控制器上下文/模型位置

发布于 2024-12-17 12:03:46 字数 283 浏览 3 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一桥轻雨一伞开 2024-12-24 12:03:47

我认为,您应该在具有控制器的项目的引用部分中添加具有模型和上下文的项目。
参考 -> 添加参考,然后浏览模型和上下文的项目。

另外,您应该将这些项目放在同一个解决方案中,以便该参考工作,并且您应该在主要项目之前在参考部分中构建项目。

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 .

无可置疑 2024-12-24 12:03:47

发现问题了!在我的解决方案中,我的 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文