How to Use AspNet.Identity core in My Sql database

前端 未结 4 1897
你的背包
你的背包 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:49

    I had to do this for a client. And I did in an application with ASP.NET Core 1.0, but for curiosity I also tried for an application in .NET Core 2.0.

    What I did was first install the Entity Framework MySQL package from https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/ using package manager console.

    After that I changed in the startup.cs, in the method ConfigureServices, the option UseSqlServer to UseMySql, like the image below.

    In my appsettings.json I have the MySQL connection named IdentityConnection like this:

    {
        "ConnectionStrings": {
            "IdentityConnection": "Server=127.0.0.1;Database=identitycoredb;Uid=root;Pwd=1234;"
        },
    

    To create the identity tables I executed the migration command in package manager console:

    EntityFrameworkCore\Update-Database -Verbose
    

提交回复
热议问题