Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use Marten
dotnet add package RavenDB.Client
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ServiceStack;
using Marten;
namespace MyApp
{
public class ConfigureMarten : IConfigureServices
{
public static List<StoreOptions> Options { get; } = new List<StoreOptions>();
IConfiguration Configuration { get; }
public ConfigureDb(IConfiguration configuration) => Configuration = configuration;
public void Configure(IServiceCollection services)
{
var store = DocumentStore.For(opts =>
{
opts.Connection(Configuration.GetConnectionString("Marten")
?? "host=localhost;username=test;password=test;database=marten");
Options.ForEach(fn => fn(opts));
});
store.Advanced.Clean.CompletelyRemoveAll();
services.AddSingleton<IDocumentStore>(store);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.