mysql - EF Code First Migrations - 两个程序集 - 查看错误的配置文件

标签 mysql entity-framework model-view-controller .net-assembly entity-framework-migrations

我有一个带有 EF6 的 MVC5 项目,我正在使用两个程序集,一个用于主网站“Goods”,其中包含 Controller 成员资格内容,另一个用于单独的程序集“Goods.Models”,具有业务域和业务逻辑,这也是使用 EF6 并连接到同一个 MySQL 数据库。

当我尝试在第二个程序集中创建迁移时出现错误:

    System.TypeInitializationException: 
The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception. ---> System.InvalidOperationException: 
The DbConfiguration type 'Goods.Setup.MySqlConfiguration, Goods' specified in the application config file could not be loaded. 
Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information. ---> 

好的,找不到“Goods.Setup.MySqlConfiguration, Goods”

我在两个程序集中都有配置文件,一个来自主前端程序集“Goods”:

<entityFramework codeConfigurationType="Goods.Setup.MySqlConfiguration, Goods">...

还有“Goods.Models”程序集中的另一个:

<entityFramework codeConfigurationType="Goods.Models.MySQLSetup.MySqlConfiguration, Goods.Models">...

我确定我在 PM 控制台中选择了 Goods.Models 程序集,但错误表明迁移框架正在查看“Goods”程序集的配置文件。

我该如何解决这个问题。

最佳答案

通过添加 -StartUpProjectName 参数解决,如下所示:

添加迁移 -StartUpProjectName Goods.Models

看来在PM控制台设置默认项目还不够

关于mysql - EF Code First Migrations - 两个程序集 - 查看错误的配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31920279/

相关文章:

.net - Entity Framework : ObjectSet and its (generics) variance

objective-c - 需要在 UIViewController 中转换 self.view 吗?

mysql - 从 MySQL 获取逗号分隔数据的查询

mysql - 使用 auto_increment 填充表的最有效方法

entity-framework - Code First EF 部署方法尝试失败

php - 更正 ZF2 重定向行为

c# - 使用请求参数的自定义名称

mysql - 每个对象的不同字段集

mysql - Windows 中是否有任何 er 图表工具可用于连接到 Unix 中的 MySQL 4.1 数据库?

c# - LINQ to SQL Func 作为输入性能