DEV Community

Cover image for RavenDB embedded with ASP NET Core web API
Ricardo Costa
Ricardo Costa

Posted on β€’ Originally published at blogit.create.pt on

5

RavenDB embedded with ASP NET Core web API

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"); 
    }
}
Enter fullscreen mode Exit fullscreen mode

g) And that’s it πŸ™‚

The post RavenDB embedded with ASP NET Core web API appeared first on Blog IT.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay