Compiled models
Version 6 of Entity Framework Core introduces the possibility to create precompiled data structures that improves Entity Framework Core performance by about 10 times in the case of models with hundreds of entities (see the reference in the Further reading section for more details). This step is accomplished by generating some code that, once compiled together with the data layer project, creates data structures that our context classes can use to improve performance.
Code is generated with the Optimize-DbContext
command provided by the Microsoft.EntityFrameworkCore.Tool
NuGet package that we already installed. The command accepts the folder name to place the code and the namespace to place all classes. In our case, let’s choose the Optimization
folder and the WWTravelClubDB.Optimization
namespace:
Optimize-DbContext -Context MainDBContext -OutputDir Optimization -Namespace WWTravelClubDB.Optimization
Where the –Context
parameter must be passed...