My question is pretty straight forward and there is some stuff out there but a lot seems to be outdated or not answer my question.
As of now, I have my connection string inside the appsettings.json and setting up the database connection as follows:
Startup.cs
services.AddDbContext<MyDbContext>(
options => options
.UseSqlServer(_configuration.GetConnectionString("ConnectionString")));
MyDbContext.cs
public class MyDbContext : DbContext
{
public MyDbContext(DbContextOptions< MyDbContext > options) : base(options) { }
...
}
However, I would like to give my users the option to dynamically choose a database by providing the connection string on login. The user therefore provides username, password and connection string when logging into the application.
Is something like that possible? If yes, please let me know how to do this. I cannot figure it out.