我启动并运行了EF6/ASP.NET 4.5 Webforms解决方案,现在我需要添加一些功能以允许从Excel文件批量插入.
我知道开箱即用的EF并没有针对批量操作进行优化,因此我环顾四周并找到了"EF BulkInsert"(https://efbulkinsert.codeplex.com/)来实现这一点.
我在一个测试应用程序中尝试过,它运行得非常好 - 但是当我将它包含在我的实际主应用程序中时,它就崩溃了.尝试执行实际的批量插入调用时,系统崩溃并出现异常:
BulkInsertProviderNotFoundException:找不到'Glimpse.Ado.AlternateType.GlimpseDbConnection的BulkInsertProvider.要注册新提供程序,请使用EntityFramework.BulkInsert.ProviderFactory.Register()方法'
现在我不确定这是否是Glimpse或EF BulkInsert(或两者)的错误,不幸的是,我似乎无法找到任何解决方案 - 这些软件的制造商都没有提供任何见解或解决方法....
有没有人在这里偶然发现了同样的问题,并找到了解决方案?
我无法使用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)