3

EF version 6 and above...

How do I use built-in OR custom EF conventions like KeyAttributeConvention, IndexAttributeConvention, etc. to change foreign key constraint names and index names?

I'm looking to change these names from one place rather than ask developers to follow naming standards for their database migrations.

For example, I don't want to use the ForeignKey method's name parameter in the migration code to specify a foreign key constraint name.

Instead, there should be a common convention configured using the model builder which performs the task when a foreign key is being generated.

Is it really possible?

jjj
  • 4,822
  • 1
  • 16
  • 39
Jackie
  • 31
  • 3
  • Maybe this would help? http://stackoverflow.com/questions/15684555/how-do-i-remove-underscore-of-foreign-key-fields-in-code-first-by-convention – jjj May 05 '15 at 17:39
  • https://msdn.microsoft.com/en-us/data/dn469439.aspx#example2 – jjj May 05 '15 at 17:39
  • This is a valid approach for FK and PK http://stackoverflow.com/a/31553476/3111429 – Kautsky Lozano Sep 02 '16 at 15:44

0 Answers0