Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework CodeFirst table pluralization

Tags:

People also ask

Should SQL tables be plural or singular?

So Which Should I Use: Singular or Plural? The correct answer is that there is no right or wrong when naming database tables — just be consistent from the start. The only wrong answer with database table names is to use a combination of plural and singular.


I'm using CodeFirst of EF with a well defined Database. My Database has a table named 'Centros' (Portuguese word) and I manage to find that EF tries to pluralize my entities to get a 'Centroes' witch is wrong in this case.

If I remove the pluralization modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); i manage to get it to work BUT I have to rename my table to 'Centro' (to match my entity name).

In Portuguese 'Centro' is singular, 'Centros' is plural.

I don't want to rename my table names so how can I specify the matching table name for my entity after a remove the pluralization convention?


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!