Open
Description
How about specifying the primary key that has a different SQL column name than my property name?
I believe the following works:
modelBuilder.Entity<MyEntity>()
.HasKey(myEntity => myEntity.MyId);
modelBuilder.Entity<MyEntity>()
.Property(p => p.MyId)
.HasColumnName("MyCustomColumnNameId");
I'm happy to update the docs with that pending confirmation it would be accepted?
Reference: https://stackoverflow.com/a/48155599/185123
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: d0a084df-15c4-ab25-26ca-83c8bdf6f026
- Version Independent ID: f1fba5b2-eb2e-da0a-fce0-d492855c1777
- Content: Keys (primary) - EF Core
- Content Source: entity-framework/core/modeling/keys.md
- Product: entity-framework
- Technology: entity-framework-core
- GitHub Login: @rowanmiller
- Microsoft Alias: divega