I have a table defined to have exactly one row, by using a boolean primary key and a unique constraint. The idea behind this was based on this post from ten years ago: One-Row by Brandstetter. This is intentional and works fine.
But EF Core Validation generates the following warning, which I would like to suppress.
warn: Microsoft.EntityFrameworkCore.Model.Validation[20600] Property 'Id' on entity type 'Config' is part of a primary or alternate key, but has a constant default value set. Constant default values are not useful for primary or alternate keys since these properties must always have non-null unique values.
How can I suppress this warning?
My table def in Postgres:
CREATE TABLE config (
id boolean PRIMARY KEY DEFAULT TRUE,
demo boolean NOT NULL DEFAULT FALSE,
version text NOT NULL,
venue text,
CONSTRAINT config_unique CHECK (id)
);
Relevant section of my DbContext.cs:
modelBuilder.Entity<Config>(entity =>
{
entity.HasKey(e => e.Id).HasName("config_pkey");
entity.Property(e => e.Id).HasDefaultValue(true);
entity.Property(e => e.Demo).HasDefaultValue(false);
});