在Startup.cs中的ConfigureServices加入
services.AddDbContext<AspCoreIThelp2020Context>();
在Controller中加入
private readonly AspCoreIThelp2020Context _context;
public HomeController(ILogger<HomeController> logger, AspCoreIThelp2020Context context)
{
_logger = logger;
_context = contex;
}
FB專頁:https://www.facebook.com/dannyliu.me