Raven DB

Raven DB is an opensource ‘document database’, it can be used to store documents.

Url: http://ravendb.net/

1] Installing

On the download page there is a zip file available, but the cool new way is to search in NuGet. So create a Visual Studio project –> Add library package reference and search for RavenDb:


Hit Install and accept license:


2] Start database

In the package folder ‘RavenDB.\Server’ there is an executable ‘Raven.Server.exe’, run it.

If you enter http://localhost:8080 a Silverlight management console turns up.

3] Coding Hello World

Create two orders, a product list and store it.

class Program


    static void Main(string[] args)


        string url="http://localhost:8080";

        var store = new DocumentStore { Url = url }; 



        using (var session = store.OpenSession())


            var product1 = new Product{Cost = 3.99m,Name = "Koffie"};

            var product2 = new Product{Cost = 3m,Name = "Soep"};

            var order = new Order(); 








    public class Product


        public string Id { get; set; }

        public string Name { get; set; }

        public decimal Cost { get; set; }



    public class Order


        public string Id { get; set; }

        public string Customer { get; set; }

        public IList<Product> Products { get; set; }


        public Order()


            Products = new List<Product>();




When you run the application, a file ‘Data’ is generated.

4]  View the database on http://localhost:8080 and search for the just inserted order:


Or type http://localhost:8080/docs/orders/1025 in a browser and get the json back.

5] Query data

With a simple query the data can be retrieved:

var orders=session.Query<Order>().ToList();

In a future post the Raven DB spatial options will be explored.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s