Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my web application I have Super Admin [MASTER_DB] module where we create multiple clients & those clients can have multiple users. For each client we have different database. I have maintained all details of clients in MASTER_DB. We input connection string from super admin for each client. We create one ADMIN USER from superadmin & with the help of that user client creates another users. Those users must be created in that client's database & all related activities should be performed on that database.

I am able to create ADMIN USER from super admin to particular clients db by using SqlMembershipProvider & SqlRoleProvider classes & updating Connection String runtime in web.config. And updated client's details using particular clients stored connection string & passing to dbContext.

C#
public partial class DBEntities : System.Data.Entity.DbContext
    {
        public DBEntities(string ConnectionString)
            : base(ConnectionString)
        {

        }
    }


We have same link for all users to access our web application. I am implementing to change the web.config files connection string at runtime once the user is validated from MASTER_DB & map that user login to particular DB. But changing connection string in web.config at runtime is not seems to be a good solution & its not working perfectly.

So anybody if implemented this scenario please guide me for the best approach to implement this; where once I get correct connection string I should map that user to correct database & apply membership functions on it. I am using Visual Studio 2012 & Entity Framework.
Posted
Updated 18-Mar-15 23:55pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900