c# - MVC5 使用来自其他命名空间的类的脚手架(引用的 DLL)

标签 c# asp.net .net asp.net-mvc-5 asp.net-mvc-scaffolding

如果模型和 DbContext 类不在同一命名空间中,是否可以使用 MVC5 脚手架使用 EntityFramework 创建带有 View 的新 Controller 。

我已经在 2 个单独的库(Project.Models 和 Project.DataAccess)中定义了模型和 dbcontext,当进入“添加 Controller ”菜单时,模型和数据上下文的下拉列表不包含我尝试使用的类。

我当然在项目中引用了它们。

最佳答案

只需确保编译您的解决方案,然后转到您的 MVC 项目并添加对模型和 dbcontext 项目的引用,这样您就可以在通过脚手架创建 Controller 或 View 时查看模型和 dbcontext 类。

关于c# - MVC5 使用来自其他命名空间的类的脚手架(引用的 DLL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22479507/

相关文章:

c# - Lambda 编译抛出 "variable ' ' of type '' referenced from scope '' , but it is not defined"

c# - 在 Xamarin Forms 中添加值后 ListView 不刷新

c# - 如何在 asp.net core 中使用 orchard .po 文件本地化来本地化数据注释属性?

asp.net - web.config 中的 "non-www to www"和 "https"重写规则,但不是 localhost ASP.NET MVC

c# - WPF:在 XP 上有 xamlparse 异常但在 Vista 上没有的任何原因?

c# - 为 Controller 中的强类型模型获取 "Key"

c# - WEB API + ASP.NET 尝试以 json 格式显示来自 WEB.API 的数据

.net - 是否可以在.NET DLL中添加/删除/更改嵌入式资源?

.net - 此代码适用于 VB,但在 VB.NET 中会出现异常,为什么?

c# - 为什么我们在调用 SmtpClient.Send 时周期性地得到 "An asynchronous call is already in progress"?