【问题标题】:EF Code First Migrations - two assemblies - looking at wrong config fileEF Code First Migrations - 两个程序集 - 查看错误的配置文件
【发布时间】:2015-08-10 13:00:22
【问题描述】:

我有一个带有 EF6 的 MVC5 项目,我正在使用两个程序集,一个用于具有控制器成员资格的主网站“Goods”,另一个用于具有业务域和业务逻辑的单独程序集“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”

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

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

以及“Goods.Models”程序集中的另一个:

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

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

我该如何解决这个问题。

【问题讨论】:

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


    【解决方案1】:

    通过添加 -StartUpProjectName 参数解决:

    add-migration -StartUpProjectName Goods.Models

    在 PM 控制台中设置默认项目似乎是不够的

    【讨论】:

      猜你喜欢
      • 2013-08-10
      • 2011-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多