I have a requirement to remove ValueGeneratedOnAdd from a guid primary key.
Pre-Migration Model Snapshot
b.HasKey("Id");
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
Change is to replace ValueGeneratedOnAdd with ValueGenerationNever. When I preform this change and add a migration the migration up and down methods are empty, but the designer for the migration reflects the change. Due to the migration up method being empty scripting the change also is empty.
Entity Type Configuration Change
builder.HasKey(s => s.Id);
builder.Property(s => s.Id)
.ValueGeneratedOnAdd();
to
builder.HasKey(s => s.Id);
builder.Property(s => s.Id)
.ValueGeneratedNever();
Generated Migration
public partial class NeverGenerateValueId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
Generated Migration Designer
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.HasKey("Id");
Generated EF MIgration Script from Last Migration to Generated Migration
START TRANSACTION;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20240206140252_NeverGenerateValueId', '7.0.15');
COMMIT;
The migration designer as you can see at least no longer reflects the ValueGeneratedOnAdd but the migration up and down as well as the migration script have nothing in them.