I have an application written in ASP.NET Core using .NET 6.0.7. And I have generated migrations and applied them to the database using database-update manually - or for production we are using the ef bundle to update the database.
This being said I am using HasData to seed initial data. This is achieved inside the OnModelCreating method in the DbContext. And whenever any of the seed data changes I cover this with a new migration.
NOTE: I do not have any migration code in the program.cs for the ASP.NET Core Web API code, but it seems that during debugging (and on production), OnModelCreating is still called - WHY?
There should be no reason to run OnModelCreating when in debug or production when starting up the Web API. Is this an error in EF Core? Or am I seriously missing something?