Skip to content

Document how key configuration and property configuration interact #1642

Open

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.

Activity

  1. changed the title [-]Primary Key w/ a Different Column Name[/-] [+]Document how key configuration and property configuration interact[/+] on Sep 2, 2019
  2. added this to the Backlog milestone on Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions