This is EF Core 3.1. I have several models with a boolean field, IsActive, defined like so:
public class Job
{
public bool? IsActive { get; set; }
}
My seed data looks like this:
modelBuilder.Entity<Job>()
.Property(e => e.IsActive)
.HasDefaultValue(true);
modelBuilder.Entity<Job>().HasData(
new Job() { IsActive = true });
Every time I create a migration (including if I run a migration with no changes made, which should generate an empty migration), it has a UpdateData call for the field above, like so:
migrationBuilder.UpdateData(
table: "Jobs",
keyColumn: "id",
keyValue: 1L,
column: "IsActive",
value: true);
I've also replicated this behavior in the TodoApi app and setup a GitHub repo for anyone interested in more details.
I understand that happening when the seed data is being generated by a function, or the result of something like DateTime.Now. I don't understand it happening here, when the column is assigned a raw boolean value during seeding.
This behavior seems very similar to issue #13047, "Incorrect UpdateData operations generated when using BoolToStringConverter with HasData", but that issue was fixed in EF Core 2.2.