How to Use AspNet.Identity core in My Sql database

前端 未结 4 1944
你的背包
你的背包 2021-02-06 07:17

I am developing one application using asp dot net core 2 using MySql database.Please help me How can i use Asp Net Identity in

4条回答
  •  迷失自我
    2021-02-06 07:27

    You Can create an Identity Database along with your MySQL Database and use the Identity database for your authorization

    This is how I do it.

       //MySQL Database 
         services.AddDbContext(options =>
                    options.UseSqlServer("Server = ; Database =MySQL  ; Trusted_Connection = True; MultipleActiveResultSets = true"));
    //Identity Database               
         services.AddDbContext(options =>
                        options.UseSqlServer("Server = ; Database = Identity; Trusted_Connection = True; MultipleActiveResultSets = true"));
    

    This should work fine along with your MySQL DB

    public class EFIdentityDbContext : IdentityDbContext
    {
        public EFIdentityDbContext(DbContextOptions options )
            :base (options)
        {
    
        }
    
    
    }
    

提交回复
热议问题