EnsureDeleted doesn't drop the table __EFMigrationsHistory

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
jamir.araujo
Posts: 22
Joined: Wed 13 Mar 2019 17:25

EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by jamir.araujo » Wed 13 Mar 2019 18:12

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by Shalex » Thu 14 Mar 2019 19:14

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.

jamir.araujo
Posts: 22
Joined: Wed 13 Mar 2019 17:25

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by jamir.araujo » Fri 15 Mar 2019 19:00

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by Shalex » Mon 18 Mar 2019 17:19

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?

jamir.araujo
Posts: 22
Joined: Wed 13 Mar 2019 17:25

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by jamir.araujo » Tue 26 Mar 2019 20:34

No. At the moment I'm using the IMigrator.Migrate("0") workaround.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: EnsureDeleted doesn't drop the table __EFMigrationsHistory

Post by Shalex » Fri 29 Mar 2019 11:54

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.

Post Reply