In my DB, the foreign keys following the following convention: category_id
, product_id
, etc...
How can I change EF's default naming convention and would I need to do it for every table?
If you want to change the default name convention for FKs, then you need to create a new one. You will find a good explanation in this link, where explain how to create a new convention to rename the FKs.
Remember add the custom convention to your context after create it:
modelBuilder.Conventions.AddBefore<System.Data.Entity.ModelConfiguration.Conventions.ForeignKeyIndexConvention>(new ForeignKeyNamingConvention());
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments