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);
}
}