C
C#10mo ago
engineertdog

.HasPrincipalKey -> Specify different column name

I need to use .HasPrincipalKey in Fluent, but I need the resulting column to be named differently from what the Fluent API wants to use. I don't see an option to override the column name to something different?
2 Replies
engineertdog
engineertdogOP10mo ago
c#
modelBuilder.Entity<PiCollectiveDigitalSet>()
.HasMany(e => e.Values)
.WithOne(e => e.PiCollectiveDigitalSet)
.HasPrincipalKey(e => e.StatesetId) // Column name for the FK should be `StatesetId` instead of `PiCollectiveDigitalSetStatesetId`
c#
modelBuilder.Entity<PiCollectiveDigitalSet>()
.HasMany(e => e.Values)
.WithOne(e => e.PiCollectiveDigitalSet)
.HasPrincipalKey(e => e.StatesetId) // Column name for the FK should be `StatesetId` instead of `PiCollectiveDigitalSetStatesetId`
leowest
leowest10mo ago
Want results from more Discord servers?
Add your server