Skip to content

Document how key configuration and property configuration interact #1642

Open
@spottedmahn

Description

@spottedmahn

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions