Add migration update all seeded data
See original GitHub issueFirst of all, I had to put on stand-by ef core 3 upgrade due to this issue https://github.com/aspnet/EntityFrameworkCore/issues/18297 duplicate of https://github.com/aspnet/EntityFrameworkCore/issues/17851 released on 3.1-preview2
Every time I add a migration, all seeded data are updated, so thousand line of code for each migration.
Here it is an example
migrationBuilder.UpdateData( table: "Countries", keyColumn: "Id", keyValue: new Guid("5c60f693-bef5-e011-a587-80ee7300c695"), columns: new[] { "CurrencyId", "DefaultLanguageId" }, values: new object[] { new Guid("7d76825e-4470-4b45-a5b9-bd96267685c0"), new Guid("deb5f6a8-2e81-47c3-bd10-a89c43919dd7") });
This has happen to me in the past only when i use DateTime.Now in seed because, obviously, the value changes every time I add a migration, but not with GUID
Further technical details
EF Core version: Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: 3.1.100-preview3-014645 Operating system: latest stable VS2019, W10
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:16 (8 by maintainers)
Fixed in a8f0f4c4dfc94975bd318a6b5a5d3a627df1d5ba
I got a similar problem: Since Microsoft.EntityFrameworkCore 3.1.0 the command “Add-Migration” updates every seeded row having a colum with a default value and using this column in the seed method.
Example:
The migration:
The code of my program is much bigger so it can be pretty hard to always remove these “wrong” migrations (cause I wanted the migration to happen only at the beginning, so I can update these seeded values later without them getting overrided on every migration).
Problem occured with: EFCore 3.1.0 and 3.1.1. Npgsql.EntityFrameworkCore.PostgreSQL 3.1.0
Worked with: EFCore 3.0.2 Npgsql.EntityFrameworkCore.PostgreSQL 3.0.1
It could be Npgsql, too - can’t test it because Npgsql depends on EFCores specific versions.