如何在My Sql数据库中使用AspNet.Identity核心 [英] How to Use AspNet.Identity core in My Sql database
问题描述
我正在使用 MySql数据库使用 asp dot net core 2 开发一个应用程序.请帮助我如何使用 Asp Net Identity MySqlDatabase .
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 MySqlDatabase.
推荐答案
我必须为客户端执行此操作.我曾经在带有ASP.NET Core 1.0的应用程序中进行过操作,但是出于好奇,我也尝试了.NET Core 2.0中的应用程序.
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.
我所做的是首先从 https://www安装Entity Framework MySQL程序包.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/使用程序包管理器控制台.
What I did was first install the Entity Framework MySQL package from https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/ using package manager console.
之后,我在 startup.cs 中的方法 ConfigureServices 中将选项 UseSqlServer 更改为 UseMySql ,如下图所示.
After that I changed in the startup.cs, in the method ConfigureServices, the option UseSqlServer to UseMySql, like the image below.
在我的appsettings.json中,我有一个名为IdentityConnection的MySQL连接,如下所示:
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
这篇关于如何在My Sql数据库中使用AspNet.Identity核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!