Reputation: 841
I have an asp.net application which I am in the process of moving away from my historic custom authentication and migrating to asp.net Identity Framework.
It is a cloud based solution and previously when a user logged in, it was getting the connection string from a generic database after a lookup using the domain name.
However, once I have got the correct database name, how can I use this with Identity, as this is where the connection string is defined:
public ApplicationDbContext()
: base("MyConStringHere", throwIfV1Schema: false)
{
}
Currently I have a method which returns a connection string depending on the customers database:
return new SqlConnection(connectionString);
But I was calling this before by passing the database name in my application, I am unsure how I can use this in the ApplicationDbContext()
Thanks
Upvotes: 0
Views: 713
Reputation: 35106
Just pass your connection string from your configurations:
public ApplicationDbContext(string myClientConnectionString)
: base(myClientConnectionString, throwIfV1Schema: false)
{
}
This is what I use in multi-tenanted application.
Upvotes: 2