npgsql / efcore.pg

Entity Framework Core provider for PostgreSQL
PostgreSQL License
1.58k stars 227 forks source link

Support `INCLUDE` for primary keys #3311

Open springy76 opened 1 month ago

springy76 commented 1 month ago

Just the same as #697 implemented years ago, but for KeyBuilder instead of IndexBuilder (see https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-PRIMARY-KEY )

Usage would be:

entityTypeBuilder.HasKey(e => new { e.A, e.B }).IncludeProperties(e => new { e.C });

pretty just the same as existing:

entityTypeBuilder.HasIndex(e => new { e.A, e.B }).IsUnique().IncludeProperties(e => new { e.C });
roji commented 1 month ago

Good catch, thanks.