Created
November 11, 2021 14:58
-
-
Save gistlyn/0007f89c6bd63856a34e475bbf618d86 to your computer and use it in GitHub Desktop.
Use Marten
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet add package RavenDB.Client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Options; | |
using Marten; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureDb))] | |
namespace MyApp | |
{ | |
public class ConfigureDb : IHostingStartup | |
{ | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices((context, services) => { | |
var store = DocumentStore.For(opts => { | |
opts.Connection(context.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