1

在我的解决方案的包管理器控制台中运行 Update-Database 时,我收到以下错误:

PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target  database.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
    at System.Reflection.RuntimeModule.GetTypes()
    at System.Reflection.Assembly.GetTypes()
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindType[TBase](String typeName, Func`2 filter, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
    at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

我在其他类似的堆栈溢出讨论中读到,有时可以通过以编程方式运行更新并捕获该异常来获得更多信息,所以我尝试了这个:

static void Main(string[] args)
{
    //https://stackoverflow.com/questions/15774247/how-to-debug-entity-framework-migration-loaderexceptions
    DbMigrator migrator = new DbMigrator(new Configuration());
    migrator.Update();
}

上面的代码实际上成功地运行了更新而没有问题(正如在应用程序初始化时由 Web 浏览器运行时的迁移一样),但是包管理器仍然在相同的 Update-Database 命令上失败并出现相同的错误。我检查了启动项目、默认项目、参考复制本地设置、重新生成 ibmmx 文件、数据库恢复,并运行多个 Visual Studio/OS 重新启动。我也尝试通过 powershell 访问异常信息,但没有找到任何东西。有谁知道获取有关包管理器操作失败原因的更多信息的方法?

具有相同基础数据库状态的相同设置(不同的数据库服务器,都在本地主机上)在另一台开发机器上没有问题,因此它似乎是特定于我的设置或安装的东西。还有其他我应该注意的“陷阱”吗?

谢谢。

更新:关于在包管理器之外工作的迁移,我可能谈得太早了。我刚刚在工作的开发机器上做了一个,把它拉到我的本地机器上,发现它不能通过网络浏览器或包管理器中的应用程序初始化工作。

4

0 回答 0