-
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathStartup.cs
More file actions
46 lines (37 loc) · 1.31 KB
/
Startup.cs
File metadata and controls
46 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using JasperFx;
using JasperFx.CodeGeneration;
using Marten;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Weasel.Core;
using Weasel.Postgresql;
namespace AspNetCoreWithMarten.Samples.ByStoreOptions;
public class Startup
{
public IConfiguration Configuration { get; }
public IHostEnvironment Hosting { get; }
public Startup(IConfiguration configuration, IHostEnvironment hosting)
{
Configuration = configuration;
Hosting = hosting;
}
public void ConfigureServices(IServiceCollection services)
{
#region sample_addmartenbystoreoptions
var connectionString = Configuration.GetConnectionString("postgres");
// Build a StoreOptions object yourself
var options = new StoreOptions();
options.Connection(connectionString);
services.AddMarten(options);
// In a "Production" environment, we're turning off the
// automatic database migrations and dynamic code generation
services.CritterStackDefaults(x =>
{
x.Production.GeneratedCodeMode = TypeLoadMode.Static;
x.Production.ResourceAutoCreate = AutoCreate.None;
});
#endregion
}
// And other methods we don't care about here...
}