0

By convention, EF generates "PK_<<Schema>>.<<TableName>>" as the backing index name for an entity primary key.

Call me a control-freak, but I like providing specific names for my primary keys, and I've been unable to locate any specific annotation or FluentAPI syntax which permits overriding the default behavior.

Am I missing something, or is this simply unavailable?

Thanks.

Sam C
  • 303
  • 2
  • 4
  • check [here](http://stackoverflow.com/questions/13607512/how-to-specify-primary-key-name-in-ef-code-first) and [here](http://stackoverflow.com/questions/13834685/how-to-change-the-name-of-a-primary-key-in-ef-code-first) – Yuliam Chandra Jul 28 '14 at 10:13
  • Thanks for the pointers. I searched before posting and didn't find those. That said, I was hoping that having control over the naming convention would be part of the FluentAPI rather than having to 'downshift' to SQL to do it manually. – Sam C Jul 28 '14 at 16:20
  • you can put your request [here](https://entityframework.codeplex.com/workitem/list/basic) – Yuliam Chandra Jul 28 '14 at 16:21

1 Answers1

0

In EF6.x you can do this by specifying a name in your migrations. The scaffolded migrations don't include a name (and therefore use a default convention) but you can edit the code to specify another name.

In EF7, all database objects will have a name specified in the model, so you won't need to drop down to Migrations to specify the names.

Rowan Miller
  • 2,090
  • 15
  • 15