在 EF 迁移中运行 SQL() 命令时,我目前遇到了 SQL 超时的问题。
情况: 我要用一个表替换超过 50 个表,并需要将这些即将删除的表的数据转换到新表中。我按照以下方式组织了迁移:
1. 创建新表。
- 在同一次迁移中,使用 SQL() 函数运行迁移数据的 sql 脚本。
3. 删除所有旧表。
目前,迁移会产生以下错误:
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
该错误发生在一个环境中,我为他们提供了一个安装程序,而他们在没有我的参与下运行它,因此我无法手动运行单个迁移,并在运行 SQL 脚本时暂停。
是否有办法更改连接的超时时间或解决此问题?
环境:
EF 6.0 Code First
SQL Server 2012