26

RavenDB has the ability to run in 'embedded' mode, which as far as I understand, should allow it to be run in a shared hosting environment.

Does anyone have any idea how it would work in an ASP.NET MVC application, and what the best practice for doing it would be?

Are there any dependencies in the hosting environment that I need to be aware of?

Bennor McCarthy
  • 11,415
  • 1
  • 49
  • 51
  • It depends on the permissions your hosting environment allows... [Embedded version in an ASP.Net hosted environment](http://groups.google.com/group/ravendb/browse_thread/thread/8f508f0d2603a8d6/cba4f0ccbe5f8d73?lnk=gst&q=embedded#cba4f0ccbe5f8d73) – sqlray Aug 19 '10 at 00:34
  • Thanks - that covers the second part of my question (i.e. dependencies), but what about a best practice for actually implementing it? – Bennor McCarthy Aug 19 '10 at 00:48
  • The download http://ravendb.net/tutorials contains an MVC sample and the google group is an active community where I am sure you can find answers to specifics. – sqlray Aug 19 '10 at 02:52
  • With shared hosting, can you access Raven Studio? If so, how do you protect it from public access? – Koen Apr 04 '12 at 12:09
  • If you're hosting on [AppHarbor](https://appharbor.com/), then that platform now has a [cloud-hosted, high-performance RavenDB add-on](https://appharbor.com/addons/ravenhq) from [RavenHQ](https://ravenhq.com/). – friism Feb 17 '12 at 19:33
  • Yeah I saw that this morning. Was going to add an answer myself, but you beat me to it. Thanks. – Bennor McCarthy Feb 17 '12 at 19:39

1 Answers1

13

Yes.

I have RavenDB running in a shared hosting environment, http://www.winhost.com/, using ASP.NET MVC 3 and RavenDB 1.0.0.371 which was released somewhere around July 2011.

My code:

public static class Store
{
    private static IDocumentStore store = createStore();

    private static EmbeddableDocumentStore createStore()
    {
        var returnStore = new EmbeddableDocumentStore();
        returnStore.DataDirectory = @"./PersistedData";
        returnStore.Initialize();
        return returnStore;
    }

    public static xxx Read(string key)
    {
        using (var session = store.OpenSession())
        {

            var anEntity = session.Query<xxx>().
                Where(item => item.key == key).Single();
            return anEntity;
        }
    }

    public static void Write(xxx)
    {
        using (var session = store.OpenSession())
        {
            session.Store(xxx);
            session.SaveChanges();
        }
    }
}

The only downside so far is I don't get the RavenDB management studio.

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
David Silva Smith
  • 11,498
  • 11
  • 67
  • 91
  • 2
    You could try use the `UseEmbeddedHttpServer = true` on the `returnStore` for the management studio -> http://ravendb.net/faq/embedded-with-http – Andrew Dec 19 '11 at 16:05
  • 1
    @David: fantastic... I've been searching for this all day. Running RavenDB in Medium Trust is a pain and currently I think it's not possible. WinHost offers Full Trust! Great. Just what I need. – Leniel Maccaferri Feb 04 '12 at 01:50