Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the connection string from nHibernate returns the string WITHOUT the password

I need to directly access the database on a nhibernate application. I am trying to get the connection string like this:

    using (SqlConnection conn = new SqlConnection(this.session.Connection.ConnectionString))

But this will return the connection string WITHOUT the password.

I'm I doing something wrong? Is there any other way to get the connection string?

like image 507
Raphael Avatar asked Feb 26 '23 09:02

Raphael


1 Answers

You can obtain a raw database connection (using the same connection details as NHibernate) from the NHibernate SessionFactory, e.g.:

IDbConnection connection = yourSessionFactory.ConnectionProvider.GetConnection()

like image 90
JulianM Avatar answered Apr 28 '23 11:04

JulianM