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.
NET Core and MySQL are both free and open source technologies. The new ASP.NET Core can run on Linux and in Linux Containers, and MySQL is one of the easiest databases to get started with. This makes the combination of ASP.NET Core and MySQL a pretty compelling combination.
To Connect to a MySQL Database Using ASP.NETFind your database's connection strings (Plesk). Note: Change the your password value to your real database password value. Using Microsoft Visual Studio . NET create an ASP.NET Project.
ASP.NET Core Identity provides a framework for managing and storing user accounts in ASP.NET Core apps. Identity is added to your project when Individual User Accounts is selected as the authentication mechanism. By default, Identity makes use of an Entity Framework (EF) Core data model.
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<EFDbContext>(options =>
options.UseSqlServer("Server = ; Database =MySQL ; Trusted_Connection = True; MultipleActiveResultSets = true"));
//Identity Database
services.AddDbContext<EFIdentityDbContext>(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<EFIdentityDbContext> options )
:base (options)
{
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With