Alex Galvão
Alex Galvão

Reputation: 37

Change property ConnectionString at runtime

is there any way to change the ConnectionString property that has application as scope at runtime?

Upvotes: 1

Views: 101

Answers (1)

Farhad Zamani
Farhad Zamani

Reputation: 5861

In this link you can use an connection string for each request. Just Change the IUserService to IConnectionStringService

public interface IConnectionStringService
{
    string GetConnectionString();
}
public class ConnectionStringService : IConnectionStringService
{
    public string GetConnectionString()
    {
        //read connection string from appSetting.json or anything
        return "";
    }
}

Upvotes: 2

Related Questions