RavenDB logo

This post describes how you can set up a simple ASP NET Core web API with Visual Studio 2017 to use an embedded RavenDB. This is a step by step tutorial.

a) You need to create a new ASP.NET Core Web Application with Visual Studio 2017
b) Choose .NET Core; ASP.NET Core 2.1; API
c) Right click the new project -> Manage NuGet packages
d) You have to add a new package source. Settings. New package source.

Name: MyGet
Source: https://www.myget.org/F/ravendb/api/v3/index.json

e) Choose the new source. Add:

RavenDB.Embedded – 4.1.1-nightly-20180904-0430
RavenDB.Client – 4.1.1-nightly-20180904-0430

f) Create a DocumentStoreHolder class


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

    public static IDocumentStore Store => store.Value;

    private static IDocumentStore CreateStore()
    {
        var serverOptions = new ServerOptions()
        {
            ServerUrl = "http://127.0.0.1:60956/",
        };
        EmbeddedServer.Instance.StartServer(serverOptions);

        return EmbeddedServer.Instance.GetDocumentStore("MyRavenDBStore");
    }
}

g) And that’s it šŸ™‚

LEAVE A REPLY

Please enter your comment!
Please enter your name here