fix(worker): add EFCore.NamingConventions and UseSnakeCase - #7
Conversation
cherninkiy
commented
May 12, 2026
- add UseSnakeCaseNamingConvention in Worker Program.cs (EF Core generates PascalCase columns, DB has snake_case fixes column p.MessageId does not exist error)
- add EFCore.NamingConventions 8.0.3 package reference
- pin version 8.0.3 (not wildcard 8.0.*)
- add UseSnakeCaseNamingConvention in Worker Program.cs (EF Core generates PascalCase columns, DB has snake_case fixes column p.MessageId does not exist error) - add EFCore.NamingConventions 8.0.3 package reference - pin version 8.0.3 (not wildcard 8.0.*)
There was a problem hiding this comment.
Code Review
This pull request configures the Worker service to use snake_case naming conventions for its database context and adds the required EFCore.NamingConventions dependency. Review feedback highlights the need to apply this same configuration to the ApiGateway project for consistency and recommends pinning the Microsoft.EntityFrameworkCore package version to 8.0.3 instead of using a wildcard to ensure environment stability.
| services.AddDbContext<AppDbContext>(options => | ||
| options.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))); | ||
| options.UseNpgsql(configuration.GetConnectionString("DefaultConnection")) | ||
| .UseSnakeCaseNamingConvention()); |
There was a problem hiding this comment.
The ApiGateway project also uses AppDbContext and maps to the same database tables (documents, processed_messages). Since these tables use snake_case columns, the ApiGateway will likely encounter the same 'column does not exist' errors unless .UseSnakeCaseNamingConvention() is also applied to its configuration and the EFCore.NamingConventions package is added to its project file.
| <PackageReference Include="EFCore.NamingConventions" Version="8.0.3" /> | ||
| <PackageReference Include="MassTransit" Version="8.5.9" /> | ||
| <PackageReference Include="MassTransit.RabbitMQ" Version="8.5.9" /> | ||
| <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.*" /> |
There was a problem hiding this comment.
The pull request description mentions pinning versions to 8.0.3 and avoiding wildcards, but Microsoft.EntityFrameworkCore is still using 8.0.*. For consistency and to prevent potential version mismatch issues between EF Core and its plugins, this should be pinned to 8.0.3 as well.
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />