Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8701501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:24:51+00:00 2026-06-13T02:24:51+00:00

I am working on creating a MVC4 multi-tenant site that uses seperate DBs for

  • 0

I am working on creating a MVC4 multi-tenant site that uses seperate DBs for each tenant and have been trying to get the membership piece to work for each tenant without any luck.

For some reason connectionStringField is always null no matter what I do. Any ideas why this could happen?

public class CodeFirstMembershipProvider : MembershipProvider
    {    
      public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)  
      { 
          base.Initialize(name, config);  

          // hard coded for testing  
          string connectionString = @"server=localhost;database=masterdb;uid=master;pwd=password";

          // Set private property of Membership provider.  
          FieldInfo connectionStringField = GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);  
          if(connectionStringField != null)
            connectionStringField.SetValue(this, connectionString);  
      }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:24:52+00:00Added an answer on June 13, 2026 at 2:24 am

    You can’t make this work. Even if you could figure out how to get the reflection to function the way you want. It will lead to instability and unexpected results.

    The reason is that the Membership Provider is a global static, single instance that is used across all concurrent users. That means if you change the connection string for one user, it changes it for all of them. Worse, you might change it for one, then have a context switch to another user and they might overwrite that change, then come back and the app isn’t in a state that it thinks it’s in.

    The built-in Membership system is not designed to have it’s internal data changed while it is running. It’s designed to use a single database for multiple applications.

    If you insist on using separate databases for each tenant, then you will have to implement your own authentication system, because Membership simply will not work in the situation you want it to. It may appear to work at first, but as your site gains more concurrent users, it’s a ticking time bomb waiting to blow up in your face.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on creating a live wallpaper lately by placing a bitmap
I have been working on creating a e-commerce store using Magento and I think
I have been working on creating a PHP email form recently and cannot manage
I'm working on creating a windows service that will send emails to a customer
I am working on creating a web app that will query event logs on
I have been having a wierd issue that is driving me absolutely crazy. It
I've been working on creating a ambient definitions file for flot as an exercise
I'm working on creating a WCF web service that communicates via JSON. I got
I'm working on creating a single command that will run mulitple things on the
I'm working on creating a dashboard. I have started to refactor the application so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.