Default Naming Conventions for Entity Framework Code First

c# entity-framework


I'm looking for a list of the Entity Framework's standard examples. Tables, I believe, are<Entity>+s as in Users... User Id is used for Foreign Keys However, I'd want to get a list of all default conventions, i.e., what the entity framework will name my objects.

I understood the conventions to be I'm not searching for such people.. I need definitions or samples of the names that Entity Framework's default practices will assign to my database objects. No conventions have been added or deleted, just to be clear. I want to know what EF's out-of-the-box default conventions are going to name my database objects since EF comes with a variety of default conventions for creating database objects.

I need this since, despite using CodeFirst, I'll be manually constructing my database objects rather than having EntityFramework create them for me (my colleague is insisting on this). In order for Entity Framework to identify and map my tables, columns, foreign keys, etc. without the need for explicit mappings, I need to know what names I should give them.


EF Default TableName Convention
      <Entity> + 's' (e.g ***Users***) 

EF Default Foreign Key Convention
      <Entity> + 'Id' (e.g ***UserId***)   

EF Default Primary Key Convention

Where do I locate this?

9/29/2016 12:36:55 AM

Popular Answer

The set of conventions that were used cannot be retrieved using EF. Only remove preconfigured conventions are available.

The documented convention list is available at MSDN.

Initially, EF permitted you to modify the conventions, but the API no longer includes that functionality.


Convention: Table Name
Default: Entity + s (e.g Users)


Convention: Foreign Key Relation
Default: Entity + Id (e.g UserId)


Convention: Primary Key
Default: Id


5/9/2012 10:58:01 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow