Running RavenDb embedded

I seem to have some trouble finding how to run RavenDb in embedded mode. This isn’t the same as my post on running RavenDb embedded for .NET 3.5. This time, I’ve already updated to .NET 4, so I should be able to use the RavenDb embedded assemblies. I’m using build 193 by the way.

The documentation on is a little out of date, but that’s normal, because RavenDb is still very actively under development. A downside of using a new technology.

But here goes. Start by referencing Raven.Client.Embedded. Instead of using a DocumentStore, you should now use an EmbeddablDocumentStore (in my version of RavenDb there’s still a typo, it should be Embeddable I believe):

var store = new EmbeddablDocumentStore { DataDirectory = @"D:\path\to\documentstore" };

You will also need a reference to Raven.Client.Lightweight, Raven.Storage.Essent (to avoid the “Could not find transactional storage type: Raven.Storage.Esent.TransactionalStorage, Raven.Storage.Esent” exception at runtime) and System.ComponentModel.Composition.

Note: At one time I got the exception: “Could not open transactional storage: D:\RavenDbTest\Data”. This was because somewhere else in my code, I was initializing the store again, when it was already initialized.