Reputation: 841
I am trying to pass a connectionString to ApplicationDbContext but it is determined from some details passed to the login page, however I can only work out how to pass it from the Startup.Auth.cs page.
My Web Application basically does a lookup in a database to work out which DB the user will connect to. I need to pass the connectionString either from passing it in the Login page or to store it somewhere and retrieve it in the Startup.Auth.cs, this is what I have so far:
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(() => ApplicationDbContext.Create("ConnectionString"));
Thanks
Upvotes: 0
Views: 491
Reputation: 32728
Don't create the ApplicationDbContext until you need to, at which point you should know the connection string to use.
Upvotes: 1