Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Created October 30, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/e85f214f80dff349a834b8607e4e841d to your computer and use it in GitHub Desktop.
Save gistlyn/e85f214f80dff349a834b8607e4e841d to your computer and use it in GitHub Desktop.
marten files
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