Case insensitive name of tables and properties in Entity Framework 6

entity-framework entity-framework-6 npgsql

Question

I am in the process of migrating the database from SQL to postgres. The application code is using Entity framework 6. I am facing issues with case sensitivity as postgres stores table, column names in lower case unless using double quotes.

The data present in postgres is in lower case (table and column names). With Entity framework 6, I am facing issues with it not been able to find the table or column names as it is trying to use Pascal case.

I have searched and found few links: Case insensitive name of tables and properties in Entity Framework 7

The above is for EF7 and most of the solutions doesn't work with EF6. I also tried to look for options in OnModelCreating but didn't find anything useful with DbModelBuilder as this is the object being passed to OnModelCreating.

I don't want to change all the entities to include the table and column names. I am wondering if one of you could help on this.

Appreciate any help.

1
0
4/16/2020 5:25:26 PM

Popular Answer

Have a look at defining some custom Conventions or using the ModelBuilder to standardize case names. (see: https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/conventions/custom) The other options are to define table and column names via the attributes/configuraion.

Personally, with PostgreSQL I elected to use PascalCase for my table/column names. It meant my manual querying needed to use quotes, but frankly I'm more comfortable looking at naming conventions that way in databases.

0
4/16/2020 11:09:40 PM


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