Default Naming Conventions for Entity Framework Code First

c# entity-framework

Question

I'm trying to find a list of examples of Entity Framework's default naming conventions. I gather that Tables are <Entity>+s e.g. Users... Foreign Keys are User_Id But I would like to see a list of all out-of-the box conventions - IE what entity framework is going to call my objects.

I'm not looking for the types of the conventions - I got that. I am looking for definitions/examples of what Entity Framework's default conventions will name my database objects. To be clear, I have not added or removed any conventions. EF comes with a number of default conventions for generating databse objects - I want to know what EF's out-of-the box default conventions are going to name my database objects.

The reason I require this is because although I am using CodeFirst, I will be creating my database objects by hand rather than making EntityFramework generate it for me (my colleague is insisting on this). Therefore I need to know what I should name my Tables, Columns, Foreign Keys...... So that Entity Framework will find/map them with no explicit mappings required.

Eg

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

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

EF Default Primary Key Convention
      ***Id***  

Where can I find this?

1
9
9/29/2016 12:36:55 AM

Popular Answer

EF does not provide a mechanism to retrieve the set of conventions used. You can only remove pre configured conventions.

You can find the documented convention list on MSDN

Initially EF allowed you to customize the conventions but now that part is removed from API.

Edit

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

PluralizingTableNameConvention

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

NavigationPropertyNameForeignKeyDiscoveryConvention

Convention: Primary Key
Default: Id

IdKeyDiscoveryConvention

9
5/9/2012 10:58:01 AM


Related Questions





Related

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