How to change default naming convention in Entity Framework CodeFirst?

Ivan-Mark Debono

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?

octavioccl

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.Conven‌​tions.ForeignKeyIndexConvention>(new ForeignKeyNamingConvention());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Prefix Column Naming Convention in Entity Framework

From Dev

How to change the naming convention on ServiceStack ORMLite

From Dev

Default physical location of Data base created in Entity Framework codefirst approach

From Dev

Entity Framework CodeFirst Migration

From Dev

How to change SQL default convention?

From Dev

How to set the isolation level for Entity Framework CodeFirst Migrations

From Dev

How to execute GO statement in Entity Framework Migrations CodeFirst

From Dev

How can I change the schema of a type that implements a particular interface in an Entity Framework 6 Custom Convention?

From Dev

entity framework 5 codefirst with mysql

From Dev

Entity Framework CodeFirst - To decorate or not to decorate

From Dev

How to change the naming convention of Many-to-Many table relationships?

From Dev

Change Naming Convention for Images Pipeline

From Dev

How to change the default calling convention in MinGW gcc

From Dev

(Code First) Entity Framework foreign keys using non standard naming convention

From Dev

Change default junction tablename in entity framework 6

From Dev

Naming convention for MongoDB in combination with Play Framework (Scala)

From Dev

Change naming convention of tags inside a git repository?

From Dev

Change foreign key constraint naming convention

From Dev

Change foreign key constraint naming convention

From Dev

In Entity Framework 5 CodeFirst, how to create a query that will return when any pair of values are found?

From Dev

Entity Framework incorrectly naming tables

From Dev

How can I change the default max length of string properties in Entity Framework 6?

From Dev

How can I change the default max length of string properties in Entity Framework 6?

From Dev

how to globally define the naming convention with Jackson

From Dev

How to define a custom naming convention if EF 5

From Dev

How to zip a pair of files with a specific naming convention?

From Dev

Entity Framework CodeFirst many to many return object null

From Dev

SQL Server 2014 Memory Optimized Table with Entity Framework 6.1 CodeFirst

From Dev

Complicated relationships vs simple tables Entity Framework CodeFirst

Related Related

  1. 1

    Prefix Column Naming Convention in Entity Framework

  2. 2

    How to change the naming convention on ServiceStack ORMLite

  3. 3

    Default physical location of Data base created in Entity Framework codefirst approach

  4. 4

    Entity Framework CodeFirst Migration

  5. 5

    How to change SQL default convention?

  6. 6

    How to set the isolation level for Entity Framework CodeFirst Migrations

  7. 7

    How to execute GO statement in Entity Framework Migrations CodeFirst

  8. 8

    How can I change the schema of a type that implements a particular interface in an Entity Framework 6 Custom Convention?

  9. 9

    entity framework 5 codefirst with mysql

  10. 10

    Entity Framework CodeFirst - To decorate or not to decorate

  11. 11

    How to change the naming convention of Many-to-Many table relationships?

  12. 12

    Change Naming Convention for Images Pipeline

  13. 13

    How to change the default calling convention in MinGW gcc

  14. 14

    (Code First) Entity Framework foreign keys using non standard naming convention

  15. 15

    Change default junction tablename in entity framework 6

  16. 16

    Naming convention for MongoDB in combination with Play Framework (Scala)

  17. 17

    Change naming convention of tags inside a git repository?

  18. 18

    Change foreign key constraint naming convention

  19. 19

    Change foreign key constraint naming convention

  20. 20

    In Entity Framework 5 CodeFirst, how to create a query that will return when any pair of values are found?

  21. 21

    Entity Framework incorrectly naming tables

  22. 22

    How can I change the default max length of string properties in Entity Framework 6?

  23. 23

    How can I change the default max length of string properties in Entity Framework 6?

  24. 24

    how to globally define the naming convention with Jackson

  25. 25

    How to define a custom naming convention if EF 5

  26. 26

    How to zip a pair of files with a specific naming convention?

  27. 27

    Entity Framework CodeFirst many to many return object null

  28. 28

    SQL Server 2014 Memory Optimized Table with Entity Framework 6.1 CodeFirst

  29. 29

    Complicated relationships vs simple tables Entity Framework CodeFirst

HotTag

Archive