Efcore: Why does EF Core pluralize table names by default?

Created on 26 Sep 2019  路  4Comments  路  Source: dotnet/efcore

As described in this post:
https://entityframeworkcore.com/knowledge-base/37493095/entity-framework-core-rc2-table-name-pluralization

I'm wondering why the EF Core team took the decision to use the name of the DbSet property for the SQL table name by default? This is generally going to result in plural table names, as that is the appropriate name for the DbSet properties. I thought this was considered bad practice, and that SQL table named should be singular - why this default?

closed-by-design customer-reported

Most helpful comment

Well it's considered a bad practice because a table already implies that multiple entites exist because it has multiple rows, so pluralizing the entity name is redundant. It results in generated key names like FK_Users_Accounts which reads better as FK_User_Account, ie. "foreign key linking a user to an account".

All 4 comments

Compatibility with EF6 mostly. 馃樁 #214 will allow you to remove the convention.

I thought this was considered bad practice, and that SQL table named should be singular - why this default?

@jez9999 can you provide any reference on this? Though it is easy to imagine different people having a strong opinion one way or the other, I cannot think of a reason this would really be a bad practice.

BTW, another thing you can do is iterate over the entities in the model using our metadata APIs in OnModelCreating and set the table name using whatever pattern you prefer.

Well it's considered a bad practice because a table already implies that multiple entites exist because it has multiple rows, so pluralizing the entity name is redundant. It results in generated key names like FK_Users_Accounts which reads better as FK_User_Account, ie. "foreign key linking a user to an account".

You can configure the names the way you want using fluent API for all table names or constraint names.

Was this page helpful?
0 / 5 - 0 ratings