0

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 Answers1

0

Have a look at defining some custom Conventions or using the ModelBuilder to standardize case names. (see: https://learn.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.

Steve Py
  • 26,149
  • 3
  • 25
  • 43
  • Thanks for replying Steve. The link you have shared looks promising, I will try it out. My issue is that the data is already inserted in the postgres. For new insertion, I should probably use the PascalCase. – user13332671 Apr 17 '20 at 02:43