[英]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. 我主要使用Fluent NHibernate,在那里我可以轻松地创建一个外键和/或主键约束命名约定,但我已经花了很多时间来弄清楚如何在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. 我希望我的PK看起来像
pkFoo
为表dbo.Foo
,我的FKS看起来像fkBar.BarId_Foo.BarId
链接表时dbo.Foo
和dbo.Bar
对类似列BarId
,与被第一字母数字首次命名表。
I took a look at inheriting from PrimaryKeyNameForeignKeyDiscoveryConvention
, but there does not seem to be a way to actually change the constraint name. 我看一下从
PrimaryKeyNameForeignKeyDiscoveryConvention
继承,但似乎没有办法实际更改约束名称。
Is this not possible in EF? 这在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 http://entityframework.codeplex.com/workitem/1226
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.