see on GitHub

Client API : How to Create a Document Store

To create an instance of the DocumentStore you need to specify a list of URL addresses that point to RavenDB server nodes.

Important

Do not open a DocumentStore using URL addresses that point to nodes outside your cluster.

using (IDocumentStore store = new DocumentStore()
{
    Urls = new[] { "http://localhost:8080" }
}.Initialize())
{

}

This will instantiate a communication channel between your application and the local RavenDB server instance.

Initialization

To be able to work on the DocumentStore, you will have to call the Initialize method to get the fully initialized instance of IDocumentStore.

Conventions

The conventions are frozen after DocumentStore initialization so they need to be set before Initialize is called.

Singleton

Because the document store is a heavyweight object, there should only be one instance created per application (singleton). The document store is a thread safe object and its typical initialization looks like the following:

public class DocumentStoreHolder
{
    private static Lazy<IDocumentStore> store = new Lazy<IDocumentStore>(CreateStore);

    public static IDocumentStore Store => store.Value;

    private static IDocumentStore CreateStore()
    {
        IDocumentStore store = new DocumentStore()
        {
            Urls = new[] { "http://localhost:8080" },
            Database = "Northwind"
        }.Initialize();

        return store;
    }
}

Note

If you use more than one instance of DocumentStore you should dispose it after use.