我有一个带有 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/