This question has been asked a couple times but none of the solutions/documentation is working for me.
Scenario - I need to build a database from scratch and edit it with migrations all from code, according to the documentation the line below should create the database from the DbContext/ModelBuilder.
_dbContext.Database.Migrate();
however this is only creating the database itself and none of the tables. If I run the below instead,
_dbContext.Database.EnsureCreated();
the database AND all the tables are created however this is not an option as I need to edit with migrations further down the line. I've tried the code below directly after the Migrate line but pendingMigrations is always 0.
var pendingMigrations = _dbContext.Database.GetAppliedMigrations().ToList();
if (pendingMigrations.Any())
{
var migrator = _dbContext.Database.GetService<IMigrator>();
foreach (var targetMigration in pendingMigrations)
migrator.Migrate(targetMigration);
}
Is there something I'm missing here? Shouldn't Database.Migrate() be creating the tables as well as the database?
Note - in testing I am deleting the database before trying another approach.


_dbContext.Database.Migrate();should create the tables. And it does it in my (and not only I guess) tests.