You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now we experience that having the Npgsql.EntityFrameworkCore.PostgreSQL reference present in the csproj file has side effects for the SQL Server migrations. If we remove the reference, the SQL Server behavior is back to normal.
Run dotnet ef migrations add InitialCreate and notice that the InitialCreate migration looks fine.
Run dotnet ef migrations add New and notice that the New migration has an AlterColumn() for all primary keys in the entities. This is unexpected.
Delete the Migrations folder, remove the reference to Npgsql.EntityFrameworkCore.PostgreSQL and re-run step 2 and 3 again, notice that the AlterColumn() calls no longer appear in the SQL Server migrations.
I know that the issue does not affect the Postgres migrations and therefore the bug might not seem relevant to this repository. If you think the issue is with the main EF Core libraries, I am happy to move it to that project instead.
Thanks,
Morten
The text was updated successfully, but these errors were encountered:
Thanks @mortenab, I've filed this as dotnet/efcore#23456 to discuss with the EF team - it's clear why this is happening, and it's also possible to work around this by explicitly specifying the provider's extension class (though that's admittedly pretty bad).
A better strategy is probably to have two fully-separate separate migration projects, each only referencing one provider - see this docs on this.
Hi,
We are using EF migrations with a code-first approach. Our application targets multiple database providers, including Postgres and SQL Server.
We generate the migrations as described in the Microsoft docs here: https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers?tabs=dotnet-core-cli#using-multiple-context-types
This has worked fine until we upgraded to .NET 5.
Now we experience that having the Npgsql.EntityFrameworkCore.PostgreSQL reference present in the csproj file has side effects for the SQL Server migrations. If we remove the reference, the SQL Server behavior is back to normal.
Repro steps
dotnet ef migrations add InitialCreate
and notice that theInitialCreate
migration looks fine.dotnet ef migrations add New
and notice that theNew
migration has anAlterColumn()
for all primary keys in the entities. This is unexpected.AlterColumn()
calls no longer appear in the SQL Server migrations.I know that the issue does not affect the Postgres migrations and therefore the bug might not seem relevant to this repository. If you think the issue is with the main EF Core libraries, I am happy to move it to that project instead.
Thanks,
Morten
The text was updated successfully, but these errors were encountered: