Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MySqlConnection.CloneWith #736

bgrainger opened this issue Nov 4, 2019 · 2 comments

Add MySqlConnection.CloneWith #736

bgrainger opened this issue Nov 4, 2019 · 2 comments


Copy link

@bgrainger bgrainger commented Nov 4, 2019

Add a new method, MySqlConnection.CloneWith(string connectionString) that returns an unopened copy of an existing connection, but with a new connection string. If the new connection string doesn't supply a password, the current connection's password is used.

This would allow (for example) pooling to be changed without disclosing the existing connection's password or requiring the calling code to know it.


var newCsb = new MySqlConnectionConnectionStringBuilder(existingConnection.ConnectionString)
    Database = "",
    Pooling = false,
var newConnection = existingConnection.CloneWith(csb.ConnectionString);

From PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#908 (comment) and similar to

Copy link
Member Author

@bgrainger bgrainger commented Nov 5, 2019

Added in 0.61.0.

Copy link

@rgarrison12345 rgarrison12345 commented Nov 5, 2019

I would actually like to see this added onto the base class DbConnection as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

No branches or pull requests

2 participants