Normally, we would have some model
public class ConnectionStrings
{
public string Sql { get; set; }
public string NoSql { get; set; }
}
then we have something in appsettings.json as follow:
"ConnectionStrings": {
"Sql": "some connection string",
"NoSql": "some other connection string"
}
Then I bind the model as follows:
services.Configure<ConnectionStrings>(
options => Configuration.GetSection("ConnectionStrings").Bind(options));
All works perfectly, but it doesn't make sense for my model to be mutable since it is holding important information. After all, configurations are static information, so once my model is read, it should stay like it is.
Is there any other way of doing this more safely?