为这个措辞奇怪的问题道歉.我不知道实际问题是什么,但希望有人可以给我一些见解.
尝试运行迁移时出现以下错误:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
Run Code Online (Sandbox Code Playgroud)
值得注意的是,在我的笔记本电脑上,这种情况并没有发生,但在我的虚拟机(天蓝色 - 大)上,这种情况发生率为100%.
我使用的是Ef 6.0.0 -rc1.请注意,更新EF不是一个选项.如果更新到EF 6.0.0或6.0.1,我将收到以下错误,100%失败率:
我也计时了错误.触发错误大约需要1.5分钟.当使用-Verboseflag 运行时,它试图创建200个带索引的表.复制sql查询并在SSMS中将其排除需要5秒.
我厌倦但没有用的一些事情:
1)ObjectContext.CommandTimeout = 36000 // 10 hours!如下所示设置:
2)在"web.config"中设置连接字符串中的超时:
connectionString="Data Source=localhost;Initial Catalog=myDB;Integrated Security=SSPI;Connection Timeout=36000"
3)设置"machine.config"事务maxTimeout:
<system.transactions>
<machineSettings maxTimeout="00:00:00" />
</system.transactions>
4)在sql server上设置"远程查询超时"
USE MyDB;
GO
EXEC sp_configure 'remote query timeout', 0 ;
GO
RECONFIGURE ; …Run Code Online (Sandbox Code Playgroud) 我试图通过执行自定义Sql使用Entity Framework Migration创建FULL TEXT索引.
我的迁移类看起来像这样:
public partial class DocumentContentFullTextIndex : DbMigration
{
public override void Up()
{
AlterColumn("dbo.Attachments", "ContentType", c => c.String(maxLength: 260));
Sql("CREATE FULLTEXT CATALOG FullTextIndexes AS DEFAULT;", true);
Sql(@"CREATE FULLTEXT INDEX ON [Attachments](
Content
TYPE COLUMN ContentType
Language 'ENGLISH'
)
KEY INDEX [PK_dbo.Attachments]
ON FullTextIndexes;", true);
}
public override void Down()
{
AlterColumn("dbo.Attachments", "ContentType", c => c.String(maxLength: null));
Sql("DROP FULLTEXT INDEX ON [Attachments]");
Sql("DROP FULLTEXT CATALOG FullTextIndexes");
}
}
Run Code Online (Sandbox Code Playgroud)
当我从MSSQL管理工作室运行它时,一切都很完美,SQL完全符合我的预期.
但是当从迁移项目运行时,第二个Sql请求会触发异常
超时已过期.操作完成之前经过的超时时间或服务器没有响应.
带-Verbose标志的完整堆栈跟踪:
Update-Database -ConnectionStringName DatabaseContext -Verbose
Using …Run Code Online (Sandbox Code Playgroud) full-text-indexing sql-server-2012 ef-migrations entity-framework-6
我在SQL Server 2008上使用Entity Framework 6.1.1,我有一个长期运行的代码第一次迁移(大约20分钟).它结束然后给出以下错误.
System.Runtime.Remoting.RemotingException: Object '/f10901d8_94fe_4db4_bb9d_51cd19292b01/bq6vk4vkuz5tkri2x8nwhsln_106.rem' has been disconnected or does not exist at the server.
at System.Data.Entity.Migrations.Design.ToolingFacade.ToolLogger.Verbose(String sql)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass30.<ExecuteStatements>b__2e()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at …Run Code Online (Sandbox Code Playgroud)