efcore / EFCore.NamingConventions

Entity Framework Core plugin to apply naming conventions to table and column names (e.g. snake_case)
Apache License 2.0
715 stars 73 forks source link

Moving from 8.0.0-rc2 to 8.0.0 broke table name #247

Closed davidsmith1307 closed 8 months ago

davidsmith1307 commented 8 months ago

Using 8.0.0-rc2 with Snake Naming on MySQL mapped the entity

public virtual DbSet<Device>? Devices { get; set; }

to the table 'devices'.

Testing 8.0.0 this morning showed that the same entity now maps to the table 'device' and breaks our app.

davidsmith1307 commented 8 months ago

FYI we had previously been using 6.0.0 with dotnet-6 with no issue. We migrated to dotnet-8 pretty much on release date and used 8.0.0-rc2 without issue.

roji commented 8 months ago

Thanks, I'll take a look at this right away.

hhyyrylainen commented 8 months ago

I just noticed that my CI tests started failing when updating from the RC (I started using that a few days ago) to the latest version today. I thought it was maybe a random test failure, but sure enough the failure isn't going away and I saw this issue immediately when I went looking for what might have caused it.

steveglen commented 8 months ago

Same here, my table names were pluralised with 8.0.0-rc2 but with 8.0.0 they are now singular. And constraint names too.

-CREATE TABLE partner_accounts (
+CREATE TABLE partner_account (

If it helps to track this down I'm using Postgresql and snake case naming convention:

optionsBuilder
    .UseNpgsql(o =>
    {
        o.UseNodaTime();
        o.MigrationsHistoryTable("ef_migrations_history");
    })
    .UseSnakeCaseNamingConvention();
roji commented 8 months ago

Apologies everyone, I've just pushed 8.0.1 with a fix to this. It should be available on nuget.org momentarily, please let me know if you see further issues.

hhyyrylainen commented 8 months ago

Just tested the 8.0.1 version and it seems to fix all of the problems I saw.

davidsmith1307 commented 8 months ago

Just tested the 8.0.1 version and it seems to fix all of the problems I saw.

Lucky You!

aradalvand commented 8 months ago

@roji I just created #253, could you please take a look? It's the same problem as the one described here, but it still persists in 8.0.1 for TPH tables names.