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

Closed
bgrainger opened this issue Nov 4, 2019 · 2 comments
Closed

Add MySqlConnection.CloneWith #736

bgrainger opened this issue Nov 4, 2019 · 2 comments
Assignees

Comments

@bgrainger
Copy link
Member

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.

Examples:

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 https://github.com/npgsql/npgsql/blob/7c44dd30144c224995e688d526276f5373c93de7/src/Npgsql/NpgsqlConnection.cs#L1297-L1315.

@bgrainger
Copy link
Member Author

Added in 0.61.0.

@rgarrison12345
Copy link

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
Development

No branches or pull requests

2 participants