Question

In C# I always use PascalCase for properties (best practice, right?), for databases i always use lowercase for tables and columnnames (best practice, right?)

When I generate classes from tables using entity framework, i get lowercase property names in C#, so I manually refactor the case in C#.

I wondered, is it best practice to use PascalCase table names and column names in the database, when the purpose of the database is to provide backing for a C# application that uses entity framework ?

Was it helpful?

Solution

You're right about Pascal Casing being right for C# properties, however I would disagree with your comment about lower casing being best practise for databases. I always thought Pascal casing was the best practise in table names and column structure. (That's what I was told by a DBA at an old job anyway and it seems to be consistent with everywhere else I've worked.)

Anyway, if your company's coding/development standards say that the database must have lower case names for columns and tables, then you have to do it. You shouldn't write a database specifically for use with Entity Framework. EF is an ORM, not a database, so the database should not care about how it's accessed.

You should design the database, sticking to any rules you have in place, and then make Entity Framework remap those columns to correct property names. It's incredibly easy to do through the Model Editor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top