Case insensitive name of tables and properties in Entity Framework 7

前端 未结 6 1871
萌比男神i
萌比男神i 2021-01-03 00:26

I use Entity Framework 7 with Npgsql adapter. Sql generated by EF seems like

SELECT \"r\".\"Id\", \"r\".\"Name\" FROM \"public\".\"Role\" AS \"r\"

6条回答
  •  攒了一身酷
    2021-01-03 01:12

    FYI version 2.1 of the Npgsql EF Core provider will only quote identifiers when that's needed (e.g. when they contain an uppercase letter).

    More importantly, everyone wanting snake case columns (or anything else besides the current behavior) can simply use the EF Core fluent API to manually specify whatever table and column name they want. It's also quite easy to write code that goes over all entities and properties, and automatically defines their database names by applying snake-case conversion or something else.

    This is better than changing any provider service, and will always work, whereas changing the SQL generation service (or any other) could be brittle.

提交回复
热议问题