UseSequenceTriggers for composite PK

15 views
Skip to first unread message

xalien

unread,
Nov 27, 2021, 9:48:57 AM11/27/21
to firebird-net-provider
Hi guys,

I use Entity Framework Core and Firebird provider.

Is it possible to have composite PK, like for example, TenantId +  Id and use single Id generation sequence? 

We had simple PK with Id column and call to 
            modelBuilder.UseSequenceTriggers();

allowed us to have this single Id generation sequence. However we decided to switch to composite PK and it just stopped working.

xalien

unread,
Nov 27, 2021, 11:00:07 AM11/27/21
to firebird-net-provider

Got it working. To achieve this you just need to manually configure Id property to have value generated on add:

            builder.HasKey(x => new { x.TenantId, x.Id });
            builder.Property(x => x.Id).ValueGeneratedOnAdd();

суббота, 27 ноября 2021 г. в 15:48:57 UTC+1, xalien:
Reply all
Reply to author
Forward
0 new messages