EF 8 migration 'up' method being executed twice
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
EF Core version: 8.0.2
Database provider: Npgsql 8.0.2
Target framework: net8.0
Operating system: Windows
I have migrated an application from EF 7 to EF 8 and noticed that the behavior of migrations seems to have changed.
```
namespace Api.Migrations
{
///
public partial class testmigration : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
Console.WriteLine("migrating");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
```
The code above will only log 'migrating' once on EF 7 (and EF6) but is being executed twice on EF8.
This is causing issues with custom migrations that execute non-idempotent logic in their 'up' command (eg creating a transaction and performing operations on the DB using an EF context rather than using the migration builder to generate the sql)
I couldn't find this change at https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-8.0/breaking-changes
Is this expected behavior?
Contributor guide
Assessment
This issue has not been assessed yet.