Microsoft doesn’t have official package to support MySQL data provider for EF Core (yet). There is an open source package
corePomelo.EntityFrameworkCore.MySql maintained by Pomelo Foundation.
We can install this package in .NET Core application using NuGet package manager.
Once package installed, setup connection string in
- Create DbContext and Model classes mapping database tables.
- Configure MySql service in
Startup.csspecifying DbContext and connection string. This service shall be queried later for resolving DbContext object via Dependency Injection.
- Accessing DbContext in controller classes
and that should be it!
Your ASP.NET Core 2 application is setup with EF Core and MySQL database.