diff --git a/EnvelopeGenerator.API/Program.cs b/EnvelopeGenerator.API/Program.cs index 38119574..a3da64df 100644 --- a/EnvelopeGenerator.API/Program.cs +++ b/EnvelopeGenerator.API/Program.cs @@ -270,12 +270,14 @@ try builder.Services.Configure(config.GetSection(CacheOptions.SectionName)); // Distributed Cache - SQL Server - var sqlCacheConfig = config.GetSection("Cache:SqlServer"); builder.Services.AddDistributedSqlServerCache(options => { - options.ConnectionString = sqlCacheConfig["ConnectionString"] ?? connStr; - options.SchemaName = sqlCacheConfig["SchemaName"]; - options.TableName = sqlCacheConfig["TableName"]; + config.GetSection("Cache:SqlServer").Bind(options); + + if (string.IsNullOrWhiteSpace(options.ConnectionString)) + { + options.ConnectionString = connStr; + } }); // Envelope generator serives