I need to use a embedded RavenDb for one of my project. I installed the Nuget Package "RavenDb.Embedded". After that, the following dlls have been added to the project:
- Raven.Abstractions
- Raven.Client.LigthWeight
- Raven.Database
My entity class for storing data:
public class TagLastRead
{
public string Id { get; set; }
public DateTime LastReceiveDateTime { get; set; }
}
I have created a RavenConfig class as follow:
public class RavenConfig
{
private static IDocumentStore _store;
public static IDocumentStore Store
{
get
{
if (_store == null)
throw new InvalidOperationException(
"IDocumentStore has not been initialized.");
return _store;
}
}
public static IDocumentStore Initialize()
{
_store = new EmbeddableDocumentStore
{
ConnectionStringName = "LocalTagReads"
};
_store.Conventions.IdentityPartsSeparator = "-";
_store.Initialize();
IndexCreation.CreateIndexes(Assembly.GetCallingAssembly(), Store);
return _store;
}
}
My app.Config file have the following line under "connectionStrings"
<add name="LocalTagReads" connectionString="DataDir = ~\Data" />
My class that needs to acces RavenDb looks like this
public class SampleClass
{
public SampleClass()
{
RavenConfig.Initialize();
}
public DoStuff(TagInfo value)
{
using(IDocumentSession session = RavenConfig.Store.OpenSession())
{
TagLastRead t = session.Load<TagLastRead>(value.Tagname);
if (t == null)
{
t = new TagLastRead();
session.Store(t,value.Tagname);
}
t.LastReceiveDateTime = value.Time;
session.SaveChanges();
}
}
}
The "Data" directory is created with some files in it and sub directories. The problem is when the following line of code is hit
TagLastRead t = session.Load<TagLastRead>(value.Tagname);
The program hang forever without any error in the output. By hitting the pause button in debug, I can see that it is stuck in MemoryStatistics class.
EDIT
I'm using version 3.0.30037
When invoking IndexCreation.CreateIndexes or session.Load or session.SaveChanges I have the following exception in the output log
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in Raven.Client.Lightweight.dll
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in mscorlib.dll
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in mscorlib.dll
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in Raven.Client.Lightweight.dll
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in mscorlib.dll
- A first chance exception of type 'Raven.Abstractions.Connection.ErrorResponseException' occurred in mscorlib.dll
After waiting for a while I have the following error
System.InvalidOperationException: Query failed. See inner exception for details. ---> System.TimeoutException: Operation timed out after: 00:01:41.1979667 ---> System.AggregateException: AsyncHelpers.Run method threw an exception. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at Raven.Client.Connection.Implementation.HttpJsonRequest.<>c__DisplayClasse.<b__d>d__10.MoveNext() in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\Implementation\HttpJsonRequest.cs:line 226