[Changeset 1911dc7cef21db6e630b9258d53584a326438cc8](https://entityframework.codeplex.com/SourceControl/changeset/1911dc7cef21db6e630b9258d53584a326438cc8) introduces a performance regression to the database creation process of up to 22% (in very large models) when compared to previous versions of this same code.
The introduction of a new call to DbModelBuilder.Build() from GetDynamicUpdateModel led to this regression. From the profile of one of our tests, it’s clear that we are calling DbModelBuilder.Build() three times:
Call 1: LazyInternalContext.CreateModel.
Call 2: EdmxWriter.WriteEdmx.
Call 3: DbContextExtensions.GetDynamicUpdateModel.
This means that for a particular test, the three calls to DbModelBuilder.Build() represent 46.2% of the time spent loading the code first model.
Comments: I think we can fix this by making creation of the ModificationCommandTreeGenerator (used to gen sproc bodies) lazy. It is this component that requires the call to GetDynamicUpdateModel.
The introduction of a new call to DbModelBuilder.Build() from GetDynamicUpdateModel led to this regression. From the profile of one of our tests, it’s clear that we are calling DbModelBuilder.Build() three times:
Call 1: LazyInternalContext.CreateModel.
Call 2: EdmxWriter.WriteEdmx.
Call 3: DbContextExtensions.GetDynamicUpdateModel.
This means that for a particular test, the three calls to DbModelBuilder.Build() represent 46.2% of the time spent loading the code first model.
Comments: I think we can fix this by making creation of the ModificationCommandTreeGenerator (used to gen sproc bodies) lazy. It is this component that requires the call to GetDynamicUpdateModel.