Hãy thử một cái gì đó khác:
Đầu tiên, trong DbContext của bạn, hãy tạo OnConfiguring phương pháp:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseMYSQL("... connection string ...");
}
Thứ hai, ngay từ đầu bạn ConfigureServices , hãy định cấu hình DbContext theo cách này:
services.AddDbContext<MyContext>();