August 2017
Intermediate to advanced
468 pages
12h 5m
English
The code in the previous section does not conform to the ASP.NET Core best practices. The best practice is to register the new service ( DbContext) during application startup, and inject it into the classes that are using it, such as MVC controllers, using Dependency Injection rather than initializing the context inline in the TextScoresDBContext class. To learn more about Dependency Injection, view the documentation at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection.
Let's take a look at the following steps:
protected override void OnConfiguring(DbContextOptionsBuilder ...