I'm experimenting with RavenDB (3.0) at the moment and trying to use the Bulk Insert feature. However although the bulk insert appears to work, I keep getting an exception right after it finishes:
An exception of type 'System.IO.EndOfStreamException' occurred in Raven.Client.Lightweight.dll but was not handled in user code
Additional information: Attempted to read past the end of the stream.
Stack trace is
at Raven.Client.Connection.ObservableLineStream.<Start>b__1(Task`1 task) in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ObservableLineStream.cs:line 39
at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
This is the code I have:
static void Main(string[] args)
{
try
{
using (var store = new DocumentStore {
Url = "http://localhost:8080/",
DefaultDatabase = "Northwind" })
{
store.Initialize();
int total = 10000;
using (var bulkInsert = store.BulkInsert())
{
for (int i = 0; i < total; i++){
bulkInsert.Store(new Employee{
FirstName = "FirstName #" + i,
LastName = "LastName #" + i});
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
Console.ReadLine();
}
}
What's odd is that the data is being written to the database (I can view it in the database browser), but also that the exception isn't being caught in my code - it's flagged as unhandled, despite the try/catch
.
I'm flummoxed as to why it might be happening, and more importantly, how I can prevent it. Anyone have any ideas?