Configuration
The .NET client reads its connection string from configuration. A typical setup binds the Cratis:Chronicle section of appsettings.json and registers Chronicle on the host with AddCratisChronicle.
appsettings.json:
{ "Cratis": { "Chronicle": { "ConnectionString": "chronicle://localhost:35000" } }}Program.cs:
builder.AddCratisChronicle(options => options.EventStore = "my-store");AddCratisChronicle is an extension on the host builder — IHostApplicationBuilder for worker and console hosts, WebApplicationBuilder for ASP.NET Core. It binds the Cratis:Chronicle section automatically, so the connection string comes from configuration rather than code. See Add Chronicle to a worker service and Add Chronicle to an ASP.NET Core app for the full host setup.
Environment-specific configuration
Section titled “Environment-specific configuration”Use per-environment configuration files to separate development and production settings:
appsettings.Development.json:
{ "Cratis": { "Chronicle": { "ConnectionString": "chronicle://localhost:35000/?disableTls=true" } }}appsettings.Production.json:
{ "Cratis": { "Chronicle": { "ConnectionString": "chronicle://clientId:clientSecret@chronicle.production.example.com:35000" } }}Environment variables
Section titled “Environment variables”You can also supply the connection string via environment variables. .NET maps the __ separator onto nested configuration keys, so Cratis:Chronicle:ConnectionString becomes:
export Cratis__Chronicle__ConnectionString="chronicle://clientId:clientSecret@server.example.com:35000"