I have a project WebApi ASP.NET Core (.NET Framework) with RavenDB Versions:
My code:
Startup class
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;
}
}
Repository
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;
}
}
}
During initialize of DocumentStore in DocumentStoreHolder class I receive error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'NLog' or one of its dependencies. The system cannot find the file specified.'
After installation NLog v4.4.11 I receive error:
Raven.Abstractions.Connection.ErrorResponseException: 'replication bundle not activated in database named: '
In another application (Console App .NET Framework) the same code working fine.
Could you help me please?
Those are exceptions that are handled internally and have no impact on the system. Just hit F5 in VS and let it run.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.