Jos*_*nks 3 entity-framework ef-migrations
我目前在EF迁移中运行SQL()命令时遇到SQL超时。
情况:我要用一个表替换一堆(> 50)表,并且需要将要放入新表中的那些表中的数据转换。我通过以下方式组织了迁移:
1.创建新表。
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代码优先
SQL Server 2012
看到这个答案。
使用Configuration.cs文件设置自定义超时:
内部密封类配置:
Run Code Online (Sandbox Code Playgroud)DbMigrationsConfiguration<ApplicationDbContext> { public Configuration() { AutomaticMigrationsEnabled = false; ContextKey = "YourDbContext"; // New timeout in seconds this.CommandTimeout = 60 * 5; } }
使用此方法,您只能更改迁移超时,而不能更改所有人使用默认连接字符串的超时。
| 归档时间: |
|
| 查看次数: |
2501 次 |
| 最近记录: |