Although the current version of ASP.NET is 6.0, I discovered that the official MySQL EF Core driver for .NET 6.0, at this time, does not work very well. Therefore, I decided to write this article for ASP.NET 5.0 Core. The NuGet package is MySql.EntityFrameworkCore Nuget located at https://www.nuget.org/packages/MySql.EntityFrameworkCore/.
Source code: https://github.com/medhatelmasry/MySqlWeb
Instead of installing and running a MySQL instance on my computer, I will run MySQL in a docker container for simplicity.
This article assumes the following:
- You have .NET 5.0 installed on your computer.
- You have Docker installed on your computer.
Setting up the MySQL 8.0.0 container
Creating an ASP.NET 5.0 Core MVC web app
Entity Framework Migrations
Test our app
This proves that your email and password was saved and that the connection to the MySQL database works as expected.