Page cover

Connection Strings

You can easily register hot-reloadable connection strings by registering them with the helper methods:

PerigeeApplication.ApplicationNoInit("ConnectionStrings", (c) => {

    //Register the connection string
    c.RegisterConnectionString("DB", "devServer");
    
    //Get the connection string later...
    string connectionString = CredentialStore.GetCredential_ConnectionString("DB");
    
    //Or get the credential, and cast it to retrieve
    if (CredentialStore.GetCredential("DB") is ConnectionStringCredentialStoreItem m) {
        var connectionStringFromCred = m.ConnectionString;
    }
});

The AppSettings.json file:

"ConnectionStrings": {
      "devServer": "data source=host;initial catalog=database; User Id=user; Password=abc"
}

Last updated