NuGet/NuGetGallery — pull request #969 by anurse (2013-03-28 05:01:44+00:00)
Title: #900 Part 5 - Stop Running Migrations on Load

This is the 5th part of a chain of pull requests that will all be pulled in together. I separated them out to make it easier to review

---

Aaaaaand finally. This is the main event. How does it work?

1. When anyone access the EntitiesContext, the EntitiesContextFactory is used to create it
2. The ECF uses DbModelManager to get the current DbCompiledModel (based on what Migrations have been run)
3. [If there isn't a current model] DbModelFactory creates the model by scanning the types and using DatabaseVersioningService to determine which RequiresMigrationAttribute-annotated properties to remove from the model
4. The ECF uses the DbCompiledModel to create the EntitiesContext

On ~/Admin/Migrations, Admins can view Pending/Applied migrations. If there are any Pending migrations, the Admin can apply them all in one shot (no partial migrations). After applying the migrations, the DbModelManager rebuilds the model and swaps it out so that future EntitiesContexts get the new model

Fixes #900