I have an asp.net core mvc site in production.
The DbInitializer was using this code: await context.Database.EnsureCreatedAsync()
Now I found out that a migration was not being applied and I've seen this:
In addition, the database that is created cannot be later updated using migrations.
I've changed code to await context.Database.MigrateAsync()
but no migrations are being applied and in my database dbo.__EFMigrationsHistory I don't see any records.
note: my solution has already 4 migration classes in the Migrations folder, but they are added in MigrationHistory. 3 of them are applied because I had once recreated the database (still using ensurecreated). The last migration is not applied, as I now didn't recreate the database as it contains data and migrations are not applied now because I used before "EnsureCreatedAsync".
How can I now apply and start using migrations in my existing database without losing any of my database data?