[更新-数据库与QUOT;命令失败,并出现TimeOut异常 [英] "Update-Database" command fails with TimeOut exception
本文介绍了[更新-数据库与QUOT;命令失败,并出现TimeOut异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ALTER TABLE MyDb ALTER COLUMN [MyColumn] [nvarchar](2)NULL
此命令失败,TimeOut异常。
尝试设置CommandTimeout i nDbContext构造函数没有任何运气。
有没有办法禁用或设置包管理器控制台EF命令的超时?
解决方案
自己找到解决方案。
由于EF5有一个新的属性> CommandTimeout 可从 DbMigrationsConfiguration
获得 内部密封类MyMigrationConfiguration:DbMigrationsConfiguration< MyDbContext> ;
{
public Configuration()
{
CommandTimeout = 10000; //迁移超时
}
}
I'm using EF migrations and have a table with a lot of data. I need to change MaxLength of a concrete column (it hadn't length constraints).
ALTER TABLE MyDb ALTER COLUMN [MyColumn] [nvarchar](2) NULL
And this command fails with TimeOut exception. Tried to setup CommandTimeout i nDbContext constructor without any luck.
Is there any way to disable or setup timeout for Package Manager Console EF commands?
解决方案
Found solution by myself.
Since EF5 there is a new property CommandTimeout which is available from DbMigrationsConfiguration
internal sealed class MyMigrationConfiguration : DbMigrationsConfiguration<MyDbContext>
{
public Configuration()
{
CommandTimeout = 10000; // migration timeout
}
}
这篇关于[更新-数据库与QUOT;命令失败,并出现TimeOut异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文