Matías Fidemraizer
Matías Fidemraizer

Reputation: 64923

Entity Framework DbContext: entities configured every time?

I'd like to know if Entity Framework System.Data.Entity.DbContext gets configured each time it's instantiated.

Why I got this question?

For example, if you're doing manual mappings overriding DbContext.OnModelCreating(...) method, it seems that this is going to be called each time a DbContext is instantiated.

Does Entity Framework perform some kind of configuration caching or whatever?

Upvotes: 1

Views: 357

Answers (1)

Eranga
Eranga

Reputation: 32437

The configured model is cached.

The EDM used by Code First for a particular context type is cached in the app-domain as an instance of DbCompiledModel.

See Code First: Inside DbContext Initialization for more info

Upvotes: 3

Related Questions