Page 1 of 1

EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Wed 13 Mar 2019 18:12
by jamir.araujo
Hi,

I'm using the package Devart.Data.PostgreSql.EFCore 7.12.1328 and I notice that the method DbContext.Database.EnsureDeleted() does not drop the table __EFMigrationsHistory.

This is an issue because, after call EnsureDeleted(), if I try to run the migrations for this DbContext again, nothing will happen.

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Thu 14 Mar 2019 19:14
by Shalex
jamir.araujo wrote: Wed 13 Mar 2019 18:12DbContext.Database.EnsureDeleted() does not drop the table __EFMigrationsHistory.
We will investigate the possibility of removing an empty __EFMigrationsHistory table by EnsureDeleted() in EF Core.
jamir.araujo wrote: Wed 13 Mar 2019 18:12This is an issue because, after call EnsureDeleted(), if I try to run the migrations for this DbContext again, nothing will happen.
By Microsoft design, EnsureCreated() / EnsureDelete() do not work with __EFMigrationsHistory. Refer to viewtopic.php?t=38197.

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Fri 15 Mar 2019 19:00
by jamir.araujo
I'm was able do figure out that calling IMigrator.Migrate("0") would circumvent the issue.
But I do disagree with your statement "By Microsoft design, EnsureCreated() / EnsureDelete() do not work with __EFMigrationsHistory".
Your own implementation for Oracle, Devart.Data.Oracle.EFCore-9.6.696, does remove the __EFMigrationsHistory table, even when the table has data.

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Mon 18 Mar 2019 17:19
by Shalex
The bug with removing an empty __EFMigrationsHistory table by EnsureDeleted() in EF Core 2 for PostgreSQL 9.0 and higher is fixed. Are you interested in the internal build with the fix?

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Tue 26 Mar 2019 20:34
by jamir.araujo
No. At the moment I'm using the IMigrator.Migrate("0") workaround.

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Posted: Fri 29 Mar 2019 11:54
by Shalex
The bug with removing an empty __EFMigrationsHistory table by EnsureDeleted() in EF Core 2 for PostgreSQL 9.0 and higher is fixed: viewtopic.php?f=3&t=38516.