Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF6 PK and FK constraint naming conventions

I primarily use Fluent NHibernate, where I can easily create a foreign key and/ or primary key constraint naming convention, but I'm having a deuce of a time figuring out how to do the same thing in EF6.

I want my PKs to look like pkFoo for table dbo.Foo, and my FKs to look like fkBar.BarId_Foo.BarId when linking tables dbo.Foo and dbo.Bar on the similar columns BarId, with the table that is alphanumerically first named first.

I took a look at inheriting from PrimaryKeyNameForeignKeyDiscoveryConvention, but there does not seem to be a way to actually change the constraint name.

Is this not possible in EF? Am I approaching this incorrectly?

like image 419
Jeremy Holovacs Avatar asked Nov 11 '22 14:11

Jeremy Holovacs


1 Answers

Check this out it does not appear like it is possible but is being tracked for future releases:

http://entityframework.codeplex.com/workitem/1226

like image 67
Shawn Avatar answered Nov 14 '22 23:11

Shawn