dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.66k stars 3.16k forks source link

Pluralization rules fail #17450

Closed piotr-mamenas closed 1 year ago

piotr-mamenas commented 5 years ago

The entity name School is improperly pluralized as "School" instead of "Schools" when running Add-Migration. I attempted to fix it by adding builder.ToTable("Schools") into the configuration but that does not generate any command in the migration.

Exception message: Object 'Schools' does not exist

Steps to reproduce

  1. Create a configuration for an entity with the name "School" using Fluent Code First Configurations
  2. Run Add-Migration XYZ
  3. The migration generated incorrectly pluralizes "School" as "School" instead of "Schools" but the queries generating engine still thinks it's "Schools" so whenever a query is executed against the collection on the context a Object 'Schools' does not exist is thrown on the context.

Further technical details

EF Core version: 2.2.6 Database Provider: SQL Server Operating system: Windows 10 Pro IDE: Visual Studio 2019 16.0 Preview 5.0

ajcvickers commented 5 years ago

@piotr-mamenas I have not been able to reproduce this. Can you please post the project/solution that you created when following the steps to reproduce?

piotr-mamenas commented 5 years ago

Thanks @ajcvickers

I am afraid this is not possible.

We managed to fix it however. Seems the DbSet was missing but there were joins defined on some of the configuration for other entity, linking to that particular entity so the table was added even despite the DbSet not there (with wrong pluralized name).