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

如何动态切换数据库连接字符串? #354

Open
TroyBug opened this issue May 10, 2024 · 1 comment
Open

如何动态切换数据库连接字符串? #354

TroyBug opened this issue May 10, 2024 · 1 comment

Comments

@TroyBug
Copy link

TroyBug commented May 10, 2024

目前有这样的需求,根据用户输入的连接字符串来连接到不同的数据库
我采用下面的方式根据用户输入的connStr重新设置连接

DBServerProvider.DbContext.Database.SetConnectionString(connStr)

但是访问到的数据还是旧的连接,请问大佬,如何让切换立即生效?

@cq-panda
Copy link
Owner

cq-panda commented May 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants