Code First 添加迁移期间的错误 [英] Errors during Code First add-migration

查看:21
本文介绍了Code First 添加迁移期间的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的添加迁移经常失败,但并非始终如一.迁移总是到达脚手架步骤,然后大约 5 次中有 4 次我们会收到如下内容:

Our add-migrations are failing routinely but not consistently. The migration always gets to the scaffolding step and then roughly 4 out of 5 times we will receive something like the following:

 System.Runtime.Remoting.RemotingException: Object '/2355037d_df43_460b_8737_725c0c1c80be/hvdculybngjc_rcnskixmk7+_2.rem' has been disconnected or does not exist at the server.at EnvDTE.Project.get_Properties()
 at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T]  (Project project, String propertyName)
 at System.Data.Entity.Migrations.Extensions.ProjectExtensions.AddFile(Project project, String path, String contents)
 at System.Data.Entity.Migrations.Utilities.MigrationWriter.Write(ScaffoldedMigration scaffoldedMigration, Boolean rescaffolding, Boolean force, String name)
 at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass3.<.ctor>b__1()
 at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object '/2355037d_df43_460b_8737_725c0c1c80be/hvdculybngjc_rcnskixmk7+_2.rem' has been  disconnected or does not exist at the server.

有时无论如何都会生成迁移类,但更多时候不会生成.对此错误的搜索表明,有一些不应该被垃圾收集的东西被垃圾收集,但这并不能真正帮助我们解决这个问题.

Sometimes the migration class gets generated anyway but more often it does not. Searches on this error have indicated that something is being garbage collected that isn't supposed to be but that doesn't really help us work around the issue.

我们的数据迁移项目在 .NET 4.5 中,EF 5 在 Windows 8、Visual Studio 2012 和 SQL Server 2012 中运行.

Our data migration project is in .NET 4.5 with EF 5 working in Windows 8, Visual Studio 2012 and SQL Server 2012.

推荐答案

这发生在我的一些长时间运行的生成新索引的脚本上.我们使用的解决方法是使用:

This happened to me on some long running scripts that generated new indexes. The workaround that we used was to use:

update-database -Script

EF 然后将 SQL 迁移输出到屏幕上,然后我们可以直接从服务器运行 SQL,因此没有超时问题.

EF then spits out the SQL migration to the screen and then we could run the SQL directly from the server so there were no timeout problems.

这篇关于Code First 添加迁移期间的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆