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

时间:2011-11-13 16:33:13

标签: ravendb ravendb-studio

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

Embedding RavenDB into an ASP.NET MVC 3 Application

现在我想访问RavenDB Management Studio(网络用户界面)。

我按照此处描述的步骤操作:Is it possible to connect to an embedded DB with Raven Management StudioRunning RavenDB in embedded mode with HTTP enabled,但我没有明白这一点。

这是我用来初始化DocumentStore

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

这是ConnectionString中的Web.config

<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?

感谢任何建议。

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

RavenDB Embedded with Management Studio UI

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

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

1 个答案:

答案 0 :(得分:12)

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

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

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

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

相关问题