When you use entity framework an "data context" class, derived from
is automatically created in the
file. This "data context" class has 3 constructors and you should use the 2nd one, that has as parameter the connection string.
So when the user change the database, you should build dynamically the connection string based on the user selection (in the most simple situation if all databases are on the same server only the name of the database should change, so you could use a static text based on the default one and replace only the param for database name by using
) then cache this connection string (for the entire user session context) and use it into your data access code like in the next example:
using (MyDataContextClasss dataContext= new MyDataContextClasss (connectionString))