This project has moved and is read-only. For the latest updates, please go here.
1
Vote

BulkInsert in parallel throws exception

description

Hi,

I am trying to do BulkInserts in parallel like this:
        Parallel.Invoke(
            () => Perform(nameof(EjerlavReplikering), () => ImporterEjerlavReplikering(sekvence)),
            () => Perform(nameof(PostnummerReplikering), () => ImporterPostnumreReplikering(sekvence))
        );
I get this exception:
System.AggregateException was unhandled
HResult=-2146233088
Message=Der opstod en eller flere fejl.
Source=mscorlib
StackTrace:
   ved System.Threading.Tasks.Task.FastWaitAll(Task[] tasks)
   ved System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
   ved System.Threading.Tasks.Parallel.Invoke(Action[] actions)
   ved Dar.CliClient.Program.ImporterAltFraStartpunkt(Int32 sekvence) i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 25
   ved Dar.CliClient.Program.Main(String[] args) i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 16
   ved System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   ved System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   ved Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   ved System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   ved System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   ved System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   ved System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   ved System.Threading.ThreadHelper.ThreadStart()
InnerException:
   HResult=-2146233088
   Message=BulkInsertProvider not found for 'System.Data.SqlClient.SqlConnection.
To register new provider use EntityFramework.BulkInsert.ProviderFactory.Register() method'
   Source=EntityFramework.BulkInsert
   StackTrace:
        ved EntityFramework.BulkInsert.ProviderFactory.Get(DbContext context) i c:\dev\EntityFramework.BulkInsert\dev\Src\EntityFramework.BulkInsert\ProviderFactory.cs:linje 68
        ved EntityFramework.BulkInsert.Extensions.BulkInsertExtension.BulkInsert[T](DbContext context, IEnumerable`1 entities, SqlBulkCopyOptions sqlBulkCopyOptions, Nullable`1 batchSize) i c:\dev\EntityFramework.BulkInsert\dev\Src\EntityFramework.BulkInsert\Extensions\BulkInsertExtension.cs:linje 87
        ved EntityFramework.BulkInsert.Extensions.BulkInsertExtension.BulkInsert[T](DbContext context, IEnumerable`1 entities, Nullable`1 batchSize) i c:\dev\EntityFramework.BulkInsert\dev\Src\EntityFramework.BulkInsert\Extensions\BulkInsertExtension.cs:linje 75
        ved Dar.Dawa.BulkInserter.Insert[T](IEnumerable`1 items, ReplikeringHistorik replikeringHistorik) i C:\Source\WireItUp\Dar\Dawa\BulkInserter.cs:linje 17
        ved Dar.CliClient.Program.ImporterPostnumreReplikering(Int32 sekvens) i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 72
        ved Dar.CliClient.Program.<>c__DisplayClass1_0.<ImporterAltFraStartpunkt>b__3() i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 27
        ved Dar.CliClient.Program.Perform(String name, Action action) i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 45
        ved Dar.CliClient.Program.<>c__DisplayClass1_0.<ImporterAltFraStartpunkt>b__2() i C:\Source\WireItUp\Dar\CliClient\Program.cs:linje 27
        ved System.Threading.Tasks.Task.InnerInvoke()
        ved System.Threading.Tasks.Task.Execute()
   InnerException: 
If I do this in sekvense it works

Any suggestions ?

comments