在ASP.NET核心的WebAPI RavenDB錯誤我有RavenDB 版本項目的WebAPI ASP.NET核心(.NET框架):用來初始化DocumentStore
- RavendDB V3.5.3
- ASP.NET核心V1 0.1
- 的.NET Framework v4.6.2
- RavenDB.Client V3.5.3
我的代碼:
啓動類
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
DocumentStoreHolder.DatabaseName = "database";
DocumentStoreHolder.Url = "http://localhost:8080/";
services.AddSingleton(DocumentStoreHolder.Store);
services.AddScoped<ISearchRepository, SearchRepository>();
}
DocumentStoreHolder
public class DocumentStoreHolder
{
private static readonly Lazy<IDocumentStore> store = new Lazy<IDocumentStore>(CreateStore);
public static string Url { get; set; }
public static string DatabaseName { get; set; }
public static IDocumentStore Store
{
get { return store.Value; }
}
private static IDocumentStore CreateStore()
{
var store = new DocumentStore
{
Url = Url,
DefaultDatabase = DatabaseName
}.Initialize();
return store;
}
}
庫
public class SearchRepository : ISearchRepository
{
private readonly IDocumentStore _store;
public async Task<string> Add(SearchRavenDto dto)
{
using (var session = _store.OpenSession())
{
session.Store(dto);
session.SaveChanges();
return dto.Id;
}
}
}
期間DocumentStoreHolder類DocumentStore的初始化我收到錯誤:
System.IO.FileNotFoundException: 'Could not load file or assembly 'NLog' or one of its dependencies. The system cannot find the file specified.'
安裝NLOG v4.4.11後我收到錯誤:
Raven.Abstractions.Connection.ErrorResponseException: 'replication bundle not activated in database named: '
在另一應用中(控制檯應用程序的.NET Framework)相同的代碼工作正常。
請問您能幫我嗎?