Tags

, ,

I have seen a few people ask how to go about accessing the RavenDB studio when they use RavenDB in embedded mode, normally you would tend to use embedded mode when unit testing.

In the following article I show you how to get the RavenDB Management Studio working in an MVC 3 application.

  1. File, New, MVC 3 Application as below:- EmbeddedMode
  2. Choose whatever you prefer in the next window, I chose Internet Application:- EmbeddedMode
  3. Now using Nuget add in the RavenDB Embedded package:- EmbeddedMode
  4. Now we need to add in some details for the application to talk to RavenDB, lets do that now, so edit the global.asax.cs file to have the following code:-
    public static IDocumentStore Store { get; set; }
    
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
    
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                    );
    }
    
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    
        Store = new EmbeddableDocumentStore { 
                                                DataDirectory = "Data",
                                                UseEmbeddedHttpServer = true
                                            };
        Store.Initialize();
    }
    
  5. Now in order to be able to view the RavenDB Management Studio we need to locate the file Raven.Studio.xap from the packages folder which was created when we added in the Nuget package above.

    The packages folder is located in the directory above the folder in which your solution currently resides, once you locate the packages folder locate the RavenDB-Embedded(version number) folder in my case this is RavenDB-Embedded.1.0.701 – the file we are looking for is in the packages\RavenDB-Embedded.1.0.701\lib\net40\

    Copy the Raven.Studio.xap to the root of your website and now try running your MVC website.

  6. Once that loads up now browse to http://localhost:8080 and the RavenDB Studio should load up – and that’s you.
  7. If you see this:- EmbeddedMode

    It means you havent copied the Raven.Studio.xap to the root of your website.

I hope this helps someone out.