If you ever made use of the global.asax startup methods in Full Framework. I actually haven’t made much use of them in the past but recently I’ve found them to be incredibly handy. They intercept the startup process and do “something” before the application starts, and only on startup. NET Core are basically like Filters in MVC. Using (var scope = ())įoreach (var context in ()) The code looks like so : public class MigrationStartupFilter : IStartupFilter where TContext : DbContext NET Core has this new paradigm of a “StartupFilter”. For example, a single machine of a low use web app probably doesn’t need all the bells and whistles for a separate database rollout, it just needs to be on the latest version at any given time.įor that. This is good for projects that the timing of the database migration really doesn’t matter or is an incredibly small rollout window. In some cases, you really don’t care when migrations are run, you just want them to migrate the database when the app starts. For example, if you roll a manual process of updating the production database, it can be useful to see if it’s actually up to date. Even then, it can be useful to know which state the database is in from an admin panel or similar just to diagnose production issues. It can also be extremely handy checking which migrations need to be run before attempting to run them. That’s it! Crazy crazy simple! Checking Pending Migrations Where _context is simply your database context. Related posts: Migrating EF Core Database From C#.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |