相关疑难解决方法(0)

批量插入在Azure SQL Server中无法正常工作

我无法使用C#webapi将大量数据插入Azure SQL服务器数据库

考虑

我想在SQL中插入60K>数据。在我的本地sql服务器中没有问题,但是在Azure SQL中,它的连接超时

我的方法:(所有人都在本地sql服务器中工作,但不在Azure sql服务器中工作)

1)使用EF对其插入记录进行一次尝试(10000次约10分钟,大多数情况下超时)

2)尝试将批量插入扩展与EF一起使用3)尝试在SqlBulkCopy中

4)尝试增加连接字符串中的连接超时

5)尝试在Dbcontext中增加命令超时。

异常StackTrace

Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
System.Data.SqlClient.SqlException (0x80131904): Execution 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.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.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 …
Run Code Online (Sandbox Code Playgroud)

c# sqlbulkcopy azure ef-bulkinsert azure-sql-database

3
推荐指数
1
解决办法
1709
查看次数