I am intermediate developer and I have a situation whereas a I have single WCF service hosted on a server that hosts a connection to a database. This is WCF service is currently accessed by a WinForms application. My customer would like to have the capability to be able to change the database being accessed when the WinForms application starts. On the database server there would be multiple separate databases that have identical structures and programability. Upon startup of the WinForms application, which connects to the one WCF service, the user would choose the database they wish to connect to. Not needing the capability of connecting to multiple databases simultaneously, just the ability to change which database to use at application startup.
This WCF use Entity Framework and I need to instantiate the context using the connection string that was sent to WCF.
What are the best way to implement this type of scenario?
Thank you.
What I have tried:
WCF:
amespace MSITrackerWS.Apps.Portal
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
public partial class PortalDB : DbContext
{
public PortalDB()
: base("name=MyConnectionString") //MyConnectionString = entry in web.config, I want to send connection string instead of having this here
{
}
public virtual DbSet<clientconfiguration> ClientConfigurations { get; set; }
}
}