第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

啟動時訪問 dbcontext

啟動時訪問 dbcontext

C#
qq_遁去的一_1 2023-09-16 19:59:10
使用 Identity 2 的 .NET MVC5 應(yīng)用程序。我需要在應(yīng)用程序啟動時調(diào)用我的服務(wù)的方法,但該方法需要訪問數(shù)據(jù)庫。我可以在哪里以及如何做到這一點?
查看完整描述

1 回答

?
繁星coding

TA貢獻1797條經(jīng)驗 獲得超4個贊

IdentityModel.cs是需要修改的地方


// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit https://go.microsoft.com/fwlink/?LinkID=317594 to learn more.

public class ApplicationUser : IdentityUser

{

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)

    {

        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType

        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

        // Add custom user claims here

        return userIdentity;

    }

}


public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

{

    public ApplicationDbContext()

        : base("DefaultConnection", throwIfV1Schema: false)

    {

    }


    public static ApplicationDbContext Create()

    {

        return new ApplicationDbContext();

    }

}

您可以創(chuàng)建多個環(huán)境變量,而不是默認連接。希望這能回答您的問題


查看完整回答
反對 回復(fù) 2023-09-16
  • 1 回答
  • 0 關(guān)注
  • 102 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號