Hello,
I am using ASP.NET Core and EF Core for the creation of a Web API. I want to use thesame Web API (same controllers, same functionalities, etc.) formultiple databases. Therefore, what I want to accomplish is giving the connection string as a parameter to a controller and change it at runtime. For example, to use DB1 database, I want to make the following request:http://www.testserver.com/api/controller1/DB1 and change the connection string of the TestDbContext (which is TestDbContext : IdentityDbContext<TestUser>) as @"Server=(localdb)\MSSQLLocalDB;Database=DB1;integrated security=True;". If I want to use the DB2 then I'll make the same request but instead of DB1, I'll place the DB2 parameter. This is how I want my Web API finally to be working.
Is this possible? Can I change the EF Core connection string at runtime from a Controller? If yes, can anyone help me with this? If this is not possible, is there any other solution?
Please, I have tries a lot but I nothing seems to be working so I need your help.
Thanks in advance.