簡體   English   中英

傳遞connectionString到ApplicationDbContext

[英]Passing connectionString to ApplicationDbContext

我正在嘗試將connectionString傳遞給ApplicationDbContext,但是它是由傳遞給登錄頁面的一些詳細信息確定的,但是我只能算出如何從Startup.Auth.cs頁面傳遞它。

我的Web應用程序基本上是在數據庫中進行查找,以確定用戶將連接到哪個DB。 我需要通過在登錄頁面中傳遞連接字符串或將其存儲在某個地方並在Startup.Auth.cs中檢索它來傳遞連接字符串,這就是我到目前為止的內容:

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

謝謝

直到需要時才創建ApplicationDbContext,此時您應該知道要使用的連接字符串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM