首页 文章

将RavenDB作为EmbeddableDocumentStore运行并访问RavenDB Management Studio

提问于
浏览
15

我正在玩Visual Studio 2010中通过NuGet安装的嵌入式RavenDB => RavenDB-Embedded.1.0.499 包 . 它在我阅读这篇优秀的MSDN文章后开始的当前项目中使用:

Embedding RavenDB into an ASP.NET MVC 3 Application

现在我想访问RavenDB Management Studio(Web UI) .

我按照这里描述的步骤:Is it possible to connect to an embedded DB with Raven Management Studio和这里Running RavenDB in embedded mode with HTTP enabled,但我没有明白这一点 .

这是我用来初始化 DocumentStore 的代码:

_documentStore = new EmbeddableDocumentStore
            {
                ConnectionStringName = "RavenDB",
                UseEmbeddedHttpServer = true
            };

这是 Web.config 中出现的 ConnectionString

<add name="RavenDB" connectionString="DataDir = ~\App_Data\Database" />

我还阅读了RavenDB: Embedded Mode中描述的步骤 . 我试图手动启动服务器:

// Start the HTTP server manually
var server = new RavenDbHttpServer(documentStore.Configuration,
documentStore.DocumentDatabase);

server.Start();

但上面的代码似乎已经过时,因为我没有 RavenDbHttpServerdocumentStore.ConfigurationdocumentStore.DocumentDatabase . 我设法找到 Raven.Database.Server.HttpServer_documentStore 中缺少其他对象 .

所以,问题是:

如何点击Web UI来可视化我的嵌入式数据库文档?我应该在浏览器地址栏中放置什么URL?

任何建议表示赞赏 .

EDIT: 我找到了让它发挥作用的方法 . 正如我在博客文章中描述的那样,它可能不是最好的方法,但确实有效:

RavenDB Embedded with Management Studio UI

注意:上述方法的一个缺点是我无法在我的应用程序中访问数据库,因为一旦服务器打开它就会被锁定 . 这样我就必须停止服务器,然后在浏览器中重新加载我的应用程序 .

我希望RavenDB的大师有更好/更正确的方法......让我们知道 .

1 回答

  • 12

    我从来没有必须手动运行服务器才能访问管理工作室 . 我通常在你的问题中没有提到的唯一几个步骤:

    // Add the following line prior to calling documentStore.Initialize()
    Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
    

    Raven.Studio.xap 复制到我的Web项目的根文件夹中 .

    当我的Web应用程序运行时,然后可以在http://localhost:8080访问RavenDB Management Studio .

相关问题