EF的迁移失败

当EF需要执行迁移的时候,

尤其是本次迁移涉及较为严重的数据结构变更

比如:

为之前的字段添加索引

添加遗漏的字段(尽量为非空,万非得以是非空的时候)

等,

那极有可能遇到错误:

 Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

------------------------------

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

此时,即便使用migrate.exe去手动执行并且/force,依旧可能失败。

需要修改的是,

Migrations目录的Configuration.cs里的构造器中添加:



            CommandTimeout = int.MaxValue;

保证执行可以完成,大不了等一等,在这种需求之下可能并没有其他更好的办法。。。。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值