What is Compiled Models in EF Core and how does it improve startup time?
Updated Apr 28, 2026
Short answer
Compiled Models pre-generate the heavy metadata model instantiation code, drastically reducing DbContext initialization time.
Deep explanation
By default, the first time a DbContext is instantiated, EF Core runs OnModelCreating, reflects over entity types, and builds a massive metadata model. For large contexts with hundreds of entities, this causes a severe cold-start delay. Compiling the model via the CLI generates static C# files that skip this runtime discovery.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro