【问题标题】:Running RavenDB as an EmbeddableDocumentStore and accessing RavenDB Management Studio将 RavenDB 作为 EmbeddableDocumentStore 运行并访问 RavenDB Management Studio
【发布时间】:2011-11-13 16:33:12
【问题描述】:

我正在使用通过 NuGet 在 Visual Studio 2010 中安装的嵌入式 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?

感谢任何建议。

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

RavenDB Embedded with Management Studio UI

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

我希望 RavenDB 的大师们有更好/正确的方法......请告诉我们。

【问题讨论】:

    标签: ravendb ravendb-studio


    【解决方案1】:

    我从来不需要手动运行服务器来访问管理工作室。我通常会在您的问题中提到的唯一几个步骤:

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

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

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

    【讨论】:

    • 天啊:这很奇怪......我试过localhost:8080,但一开始没有用。现在我什至没有添加EnsureCanListenToWhenInNonAdminContext就让它工作了。去搞清楚。我想我在第一次尝试时在端口 8080 上运行了另一项服务......谢谢约翰!
    • 这可行,但如果我调试单元测试,它会停止 HTTP 服务器的执行,因此除非我不调试,否则我无法使用它,这意味着我无法调试我的测试并查看工作室,这意味着这是没用的。有没有办法避免这种情况?
    猜你喜欢
    • 1970-01-01
    • 2018-04-13
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多