【发布时间】:2015-12-12 06:44:08
【问题描述】:
我想将 ASP.NET MVC 6 与启用迁移的 Entity Framework 6 一起使用。我的 Entity Framework 6 DbContext 位于与 MVC 6 项目不同的程序集中。我可以让 Entity Framework 6 与 MVC 6 一起工作,但是一旦我启用迁移,我就会收到一个 FileNotFoundException 和消息 Could not find file '{AssemblyName}.resources'.
有没有办法让 MVC 6 与带有迁移的 EF 6 一起工作?
这是我放在 GitHub 上的一个测试项目,用于演示该问题:https://github.com/johnnyoshika/mvc6-ef6-migrations
【问题讨论】:
-
你能继续吗?一些微软组件使用“try and if not found create”机制来创建内部结构(例如 System.Xml 的 Xsl 部分做类似的事情)...
-
当你遇到这个错误时你会怎么做?
-
感谢 cmets @StephenReindl 和 @JotaBe!我将在今天晚些时候检查我是否可以继续通过此异常。
-
对我来说完全一样——“FileNotFoundException 未被用户代码处理”,所以服务器只响应 500 Internal Server Error。代码只是创建上下文并在发生时尝试添加记录。
-
我看到与@DmitryNogin 相同的结果。 FileNotFoundException 导致 500 错误。这是我放在 GitHub 上的一个测试项目,它演示了这个问题:github.com/johnnyoshika/mvc6-ef6-migrations
标签: asp.net-mvc entity-framework entity-framework-6 asp.net-core-mvc