Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自定义SQL迁移超时异常?

自定义SQL迁移超时异常?

提问于 2018-01-24 20:27:44
回答 2关注 0查看 362

迁移类如下所示:

代码语言:javascript
运行
AI代码解释
复制
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");
    }

带有详细标志的完整堆栈跟踪:

代码语言:javascript
运行
AI代码解释
复制
Update-Database -ConnectionStringName DatabaseContext -Verbose
Using StartUp project 'Lx2'.
Using NuGet project 'Database.Model'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'Lx2' (DataSource: ., Provider: System.Data.SqlClient, Origin: Explicit).
Applying explicit migrations: [201406050348083_AttachmentsContentFullTextIndex].
Applying explicit migration: 201406050348083_AttachmentsContentFullTextIndex.
ALTER TABLE [dbo].[Attachments] ALTER COLUMN [ContentType] [nvarchar](260) NULL
CREATE FULLTEXT CATALOG FullTextIndexes AS DEFAULT;
CREATE FULLTEXT INDEX ON [Attachments](
Content
    TYPE COLUMN ContentType
    Language 'ENGLISH'
)
KEY INDEX [PK_dbo.Attachments]
ON FullTextIndexes;
System.Data.SqlClient.SqlException (0x80131904): 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

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
   at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement, DbInterceptionContext interceptionContext)
   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 System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
ClientConnectionId:3d298f0a-e2dc-4976-8587-c69d03b23c6b
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

更新

代码语言:javascript
运行
AI代码解释
复制
AlterColumn("dbo.Attachments", "ContentType", c => c.String(maxLength: 260));

回答 2

Balthazar00

发布于 2018-01-25 05:55:31

您的请求处理可能需要比实体框架的默认命令超时(30秒)更多的时间。如果需要,可以增加命令超时,如下面的线程

实体框架超时

Mr.Crypto

发布于 2018-01-25 04:28:13

使用Configuration.cs文件设置自定义超时:

代码语言:javascript
运行
AI代码解释
复制
internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
        ContextKey = "YourDbContext";

        // New timeout in seconds
        this.CommandTimeout = 60 * 5; 
    }
}
和开发者交流更多问题细节吧,去 写回答
相关文章
dubbo超时异常
在调用dubbo服务时经常看到如下错误: Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer.
一笠风雨任生平
2019/08/02
6.9K0
Python - 函数超时异常处理
python 自带的 信号量 可以作为计时装置参与超时异常检测,支持 Linux,Windows 支持不佳
为为为什么
2022/08/04
3K0
异常 & 自定义异常 & 常见异常
首先定义一个类 让其继承Exception 或者 RuntimeException 在其构造方法里面
收心
2022/01/17
1.5K0
控制台打印异常,页面显示异常,http获取链接超时异常
工作中,对于异常的抛出讲究的是异常信息是尽量精确的,因此抛出到前台的异常大都是我们自己编写的异常信息。
全栈程序员站长
2022/06/30
7940
AJAX请求超时与网络异常处理
在进行 AJAX(Asynchronous JavaScript and XML)请求时,我们经常需要处理请求超时和网络异常的情况。超时处理可以防止请求时间过长导致用户体验不佳,而网络异常处理可以帮助我们捕获请求失败的情况并进行相应的处理。
堕落飞鸟
2023/05/18
3.9K0
测试框架-TestNG-超时测试、异常测试
2、执行脚本(TimeOutTest鼠标右键Run As--->TestNG Test)。
wangmcn
2022/07/25
8140
测试框架-TestNG-超时测试、异常测试
重写request设置自定义超时
主要继承HttpServletRequestWrapper后取得对应的session后进行自定义业务处理 public class SessionInvalidationFilter implements Filter { private static final Logger LOGGER = Logger.getLogger(SessionInvalidationFilter.class); private static final String LAST_ACCESS_SESSION
用户1418372
2018/09/13
1.5K0
python自定义异常处理_Python 自定义异常
Python有许多内置的异常,当其中的某些错误出现时,它们会强制您的程序输出错误。
用户7886150
2021/01/21
1.3K0
python自定义异常捕获异常处理异常
参考链接: Python自定义异常 def set_inf(name,age):     if not 0 < age < 120:         raise ValueError('超出范围')     else:         print('%s is %s years old' % (name,age)) def set_inf2(name,age):     assert 0 < age < 120,'超出范围'     print('%s is %s years old' % (name,ag
用户7886150
2021/01/22
1.6K0
自定义异常
自定义异常类 Tset.java public class Test { public static void main(String[] args) { String name="程序员";  try {     if(!name.equals("程序猿"))        {         //抛出异常          throw new TestException1(name+"不是程序猿");          }    }  catch (TestException1 e)
sr
2018/08/20
5130
Harbor记异常迁移恢复实践
描述: Harbor 是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源 Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。
全栈工程师修炼指南
2022/09/29
1K0
Harbor记异常迁移恢复实践
自定义异常
将RuntimeException更改为Exception异常时,把运行时异常改为编译时异常,在编译时就要对异常进行处理,进行try-catch处理、或者throws进行处理;
ha_lydms
2023/08/09
1960
自定义异常
MySQL异常迁移恢复实践记录
描述: 在K8s集群中里利用bitnami提供的mysql:5.7.32-debian-10-r61镜像并利用helm进行MySQL集群的部署安装, 在进行网络调整后发现mysql-master-0 pod无法正常启动,导致MySQL数据库无法访问,同时设定的root密码被更改导致无法提取持久化目录中相关数据信息,我们可以依据如下方式进行错误排查以及数据恢复。
全栈工程师修炼指南
2022/09/29
8500
Oracle SQL 异常处理
有预定义异常 与 用户自定义异常 还有 raise_application_error()函数 raise_application_error() 只能把异常抛出而不能处理异常。
星哥玩云
2022/08/17
8200
Oracle SQL 异常处理
Java 如何抛出异常、自定义异常
1、定义 : 一个方法不处理这个异常,而是调用层次向上传递,谁调用这个方法,这个异常就由谁来处理。
Java编程指南
2019/08/02
5.1K0
Java 如何抛出异常、自定义异常
【Go】异常处理之自定义异常
package main import ( "fmt" "math" ) type IRE struct { Radius float64 MinRadius float64 MaxRadius float64 } func newIRE(radius float64) *IRE { ire := new(IRE) ire.MinRadius = 5 ire.MaxRadius =50 ire.Radius = radius return ire } func (ire *I
Regan Yue
2021/09/16
5800
【Go】异常处理之自定义异常
Python 自定义异常与抛出异常
自定义异常与抛出异常 自定义抛出异常raise 将信息以报错的形式抛出 用法 rais 异常类型(message) 参数 message:错误信息 返回值 无返回值 自定义异常类 继承基类——Exception 在构造函数中定义错误信息 代码 # coding:utf-8 def test(number): if number == 100: raise ValueError('number 不可以是100') return number # result = test
Zkeq
2022/05/18
8290
Java 如何抛出异常、自定义异常[通俗易懂]
1、定义 : 一个方法不处理这个异常,而是调用层次向上传递,谁调用这个方法,这个异常就由谁来处理。
全栈程序员站长
2022/07/29
5.1K0
Java 如何抛出异常、自定义异常[通俗易懂]
Java(自定义异常)
子父类异常: 如果父类抛出了多个异常,子类重写父类方法时,抛出和父类相同异常,或者是父类异常的子类,再或者不抛出异常; 父类方法没有抛出异常,子类重写父类方法也不可抛异常。如果子类发生异常,只能捕获处理,不能声明抛出; 父类异常什么样,子类异常就什么样; 自定义异常: Java提供的异常类,不够我们使用的时候就需要自己定义一些异常类。 格式: public class XXXException extends Exception/RuntimeException{ 添加一个空参构造方法 添加
全栈开发日记
2022/05/12
4820
Java自定义异常
为什么需要自定义异常类: 我们说了Java中不同的异常类,分别表示着某一种具体的异常情况,那么在开发中总是有些异常情况是SUN没有定义好的,此时我们根据自己业务的异常情况来定义异常类。例如年龄负数问题,考试成绩负数问题等等。 在上述代码中,发现这些异常都是JDK内部定义好的,但是实际开发中也会出现很多异常,这些异常很可能在JDK中没有定义过,例如年龄负数问题,考试成绩负数问题.那么能不能自己定义异常呢? 什么是自定义异常类: 在开发中根据自己业务的异常情况来定义异常类. 自定义一个业务逻辑异常: RegisterException。一个注册异常类。 异常类如何定义:
共饮一杯无
2022/11/28
5130

相似问题

SQL sever数据库能迁移至TDsql数据库吗?

272

怎样把网站转到腾讯云?

3496

获取签名超时?

41.2K

请问腾讯云 迁移备案的在哪里迁移?

3596
相关问答用户
中建数科 | 技术总监架构部总经理擅长3个领域
公司公司公司公司公司公司 | 职务职务职务职务职务职务擅长3个领域
腾讯云TDP | 先锋会员擅长2个领域
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档