RavenDb EnsureDatabaseExists extension method

Just a quick hint for others like me, who spent some minutes searching for the EnsureDatabaseExists method when trying to use RavenDb with  Multi-Databases. EnsureDatabaseExists is an extension method on IDatabaseCommands defined in the Raven.Client.Extensions namespace. To make it work you need to add a using statement for this namespace.

using Raven.Client;
using Raven.Client.Extensions;

using (DocumentStore store = new DocumentStore()
{
    Url = "http://localhost:8080/" 
})
{
    store.Initialize();
    store.DatabaseCommands.EnsureDatabaseExists("SomeDatabase");
}
  • Alexander

    Or let Resharper find the method for you ;)

  • http://www.erata.net Iulian Margarintescu

    I’ve tried installing re-sharper two times already. After about 30 minutes i’ve uninstalled it every time. I know it is a great tools since a lot of really smart people are using it, and i promise to try it again, but my impression was that it was trying to help me every time i press a key – and that was very distracting – i mean can I write a bunch of code and maybe get help only if i ask for it? I admit I did not spend any time learning how i should use it or trying to configure it … but somehow by default it seem too intrusive for my taste. Maybe the 3rd time will become friends but i have my doubts now that i’m doing a lot of stuff in sublime editor and i enjoy it.

    (somehow disqus only relayed your message after 2 months… )