Open benedict-odonovan opened 2 years ago
Fixing this properly won't be possible until https://github.com/dotnet/efcore/issues/27973, https://github.com/dotnet/efcore/issues/27972 and https://github.com/dotnet/efcore/issues/27971 are fixed. The best that can be done for EF 7 is skipping objects on entity types using TPC or entity splitting
Note that this was also filed as #185. Until EF-side support is available, I've at least removing the rewriting for 8.0.0 - index names in this case aren't rewritten, but at least they don't cause duplicate name errors. Keeping this issue to track properly rewriting.
Was pointed here from the dotnet/efcore repository.
The preview versions of EF7 support Table per Concrete Type inheritance which is currently incompatible with
.UseSnakeCaseNamingConvention
. Generated indexes use the name of the parent type rather than that of the child type, causing migrations to fail because of duplicate index names.Entity Models:
In EntityContext.cs:
In Startup.cs:
In the generated migration:
When update-database is run the following error is returned:
42P07: relation "ix_base_entity_trackables_created_by_id" already exists
System Info: EF Core version: 7.0.0-preview.7.22376.2 EFCore.NamingConventions version: 6.0.0 Database provider: Npgsql.EntityFrameworkCore.PostgreSQL:7.0.0-preview.7 Target framework: (e.g. .NET 5.0) .NET 6.0 Operating system: Windows 10 IDE: (e.g. Visual Studio 2019 16.3) Visual Studio 2022 17.3