Martin Schmeller
Martin Schmeller

Reputation: 3

How to force DbContext refresh connection string from config

how can I force DbContext to reread a Connection string from config without restart my application? I Change the Password in the config Connection string. I create a new instance of DbContext with the Name=xxxx constructor. But in DbContext.Database.ConnectionString still is the old Password!?

Upvotes: 0

Views: 2273

Answers (2)

Pawel
Pawel

Reputation: 31620

Instead of passing the name of the connection string from the config file you can just pass the connection string to the ctor.

Upvotes: 1

phil soady
phil soady

Reputation: 11348

 ConfigurationManager.RefreshSection("xxx")

EDIT:

Looks Like EF Caches, so even teh refresh doesnty work apparently. so try this EF Runtime connection strings

Upvotes: 0

Related Questions