RavenDb初始化不起作用

时间:2013-01-19 17:07:37

标签: asp.net-mvc-4 ravendb

这是我的环境:
* Windows 7
*安装了RavenDb.Embedded与NuGet,最终拉出版本2.0.2230
* IIS 7
* VS2012 Express
* MVC 4 *在调试模式下运行。

Web.config部分......

<connectionStrings>  
  <add name="RavenDb" connectionString="DataDir = ~\RavenData" />  
</connectionStrings>  
<appSettings>  
  <add key="webpages:Version" value="2.0.0.0" />  
  <add key="webpages:Enabled" value="false" />     
  <add key="PreserveLoginUrl" value="true" />   
  <add key="ClientValidationEnabled" value="true" />  
  <add key="UnobtrusiveJavaScriptEnabled" value="true" />  
  <add key="RavenDb/Port" value="8081" />  
  <add key="RavenDb/DataDir" value="~\RavenData" />  
  <add key="RavenDb/AnonymosAccess" value="Get" />  
</appSettings>  

应用程序启动时的代码是....

// Test getting create connection to new ravenDB
IDocumentStore test = new EmbeddableDocumentStore
{
    ConnectionStringName = "RavenDb",
    UseEmbeddedHttpServer = true
};
test.Initialize();

//never get to this line
int x = 12;

确实创建了乌鸦文件。但是代码永远不会达到x = 12.它看起来陷入无限循环。我从来没有收到错误消息。

1 个答案:

答案 0 :(得分:0)

我能够使用您的配置。如果你想看到这里的代码。

https://github.com/khalidabuhakmeh/MvcRavenDbEmbedded

我会发布最重要的部分。

namespace EmbeddedRavenSite
{
    public class MvcApplication : System.Web.HttpApplication
    {
        public IDocumentStore DocumentStore;

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            DocumentStore = RavenConfig.Init();
        }
    }
}

和RavenConfig类:

namespace EmbeddedRavenSite.App_Start
{
    public static class RavenConfig
    {
        public static IDocumentStore Init()
        {
            return new EmbeddableDocumentStore
            {
                ConnectionStringName = "RavenDb",
                UseEmbeddedHttpServer = true
            }.Initialize();

        }
    }
}

希望有所帮助。我包含的代码包含NuGet包恢复,因此您应该能够立即构建并开始工作。祝你好运:)