title: How to read config values from a custom DriverConnectionProvider with Fluent NHibernate?
body: <p>I'm currently implementing MSI for Sql Server in a project that uses NHibernate, to get this I created a custom DriverConnectionProvider. The thing is that I need to set access token now and to get the access token I need to read a client id from the config file. Is there a way to pass parameters into the custom DriverConnectionProvider?</p>
  <p>This is what I have:</p>
  <pre><code>public class MsiConnectionProvider : DriverConnectionProvider
  {
      public override DbConnection GetConnection(string connectionString)
      {
          var credential = new DefaultAzureCredential(
              new DefaultAzureCredentialOptions
              {
                  ManagedIdentityClientId = &quot;Hard Coded Client Id&quot; //I want to set this using a config variable
              }); 
  
          var tokenReq = new TokenRequestContext(new[] { &quot;Hard Coded Resource Id&quot; }); //I want to set this using a config variable
          var accessToken = credential.GetToken(tokenReq);
  
          var conn = (SqlConnection)Driver.CreateConnection();
          try
          {
              conn.AccessToken = accessToken.Token;
              conn.ConnectionString = ConnectionString;
              conn.Open();
  
          }
          catch (Exception)
          {
              conn.Dispose();
              throw;
          }
  
          return conn;
      }
  }
  </code></pre>
  <p>It is supposed that the custom DriverConnectionProvider is called automatically after being set up. So I don't find a way to pass those values. Any ideas?</p>
  <p>Thanks in advance.</p>