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 pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Entity Framework interview questions

View all →