是什么导致了这个 Entity Framework 6 运行时错误 - 类型或命名空间不存在?

问题描述

这是一个 ASP.NET(Framework v. 4.5.2)网站,目前在生产环境中可靠运行。一项新要求要求向已完成的现有 sql Server 表 (apProduct) 添加新列。然后我对 .edmx 文件、控制器、视图等进行了必要的更改,一切都编译正常。但是,我现在收到以下运行时错误

enter image description here

当我调试并在第一次创建 apDepartment 的地方设置断点时,我展开创建的对象并看到:

enter image description here

我注意到:“‘EntityFrameworkDynamicProxies-AnkoMVC’的元数据无效。”

这里是定义 apProduct 的地方,很明显在 AnkoMVC.Models 命名空间中:

enter image description here

最后,这里是 DbContext 类:

enter image description here

谁能提供有关如何克服这个问题的建议?

解决方法

我在许多视图的@model 参考中发现了问题。这是错误的代码:

enter image description here

这是更正后的@model 参考:

enter image description here

谢谢!