Entity Framework DbContext: ¿entidades configuradas cada vez?

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 es instanciado

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

preguntado el 31 de julio de 12 a las 10:07

1 Respuestas

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.

Ver Código primero: inicialización interna de DbContext para más información

Respondido 31 Jul 12, 10:07

Let's see what's in that link! - Matías Fidemraizer

Pay attention to the fact I'm not using an auto-generated EDMX or model, but I want to directly use DbContext and configure mappings using DbContext's fluent interface. Does this apply to my case too? ¡Gracias! :) - Matías Fidemraizer

@MatíasFidemraizer Yes. The blog post describe the process used in Code First model initialization. If it is not sufficient you can go through the fuente - Eranga

Ok, nice! Thanks for the info. +1 - Matías Fidemraizer

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.