如何在 My Sql 数据库中使用 AspNet.Identity 核心 [英] How to Use AspNet.Identity core in My Sql database
问题描述
我正在开发一个使用 asp dot net core 2 的应用程序,使用 MySql 数据库.请帮助我如何使用 Asp Net IdentityMySql 数据库.
我不得不为客户做这件事.我在 ASP.NET Core 1.0 的应用程序中做了,但出于好奇,我也尝试了 .NET Core 2.0 中的应用程序.
我首先从
在我的 appsettings.json 中,我有一个名为 IdentityConnection 的 MySQL 连接,如下所示:
<代码>{连接字符串":{"IdentityConnection": "Server=127.0.0.1;Database=identitycoredb;Uid=root;Pwd=1234;"},
为了创建身份表,我在包管理器控制台中执行了迁移命令:
EntityFrameworkCoreUpdate-Database -Verbose
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.
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:
EntityFrameworkCoreUpdate-Database -Verbose
这篇关于如何在 My Sql 数据库中使用 AspNet.Identity 核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!