Sunday, September 30, 2018

how not to do database initialization strategies with Entity Framework

Page 175 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis discusses the database management patterns/database initializers/DbInitializers of the early Code-First flavors of Entity Framework before version 7, what is being referred to as EF Core. Out of the box there were four of these:

  • CreateDatabaseIfNotExists
  • DropCreateDatabaseIfModelChanges
  • DropCreateDatabaseAlways
  • MigrateDatabaseToLatestVersion

 
 

Anymore all database initialization stuff is done with PowerShell commands and there are few C# commands. There are three right on the DbContext like so...

  • Database.EnsureCreated()
  • Database.EnsureDeleted()
  • Database.Migrate()

 
 

...but the book eludes to these not being the main focus. I don't know if it will even circle back to them. I'm expecting to be working in PowerShell. Anyways, the four database management patterns/database initializers/DbInitializers could all be inherited from and then extended by way of overriding methods. The book suggests that they were bad because they required a hardcore geek level of knowledge of Entity Framework that was not inclusive to anyone trying to just get their feet wet. From my own experience I found the showstopper for Code First stuff to really lie in this pain point too. I guess the next few pages ahead will allow me to form an opinion as to whether or not anything has gotten better.

No comments:

Post a Comment