简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM