efcore / EFCore.FSharp

Adds F# design-time support to EF Core
MIT License
234 stars 26 forks source link

Missing calls to HasIndex in ContextModelSnapshot.fs after scaffolding #102

Closed LiteracyFanatic closed 3 years ago

LiteracyFanatic commented 3 years ago

Describe the bug Scaffold an existing table that has an index with a name which differs from the default index name EF Core would use. The resulting DbContext will contain the appropriate calls to HasIndex to use the existing names. Then create a new migration. The calls to HasIndex will be missing the original names in the migration and snapshot file. Subsequent migrations will try to sp_rename from the default index name to the existing index name. Because the default index name does not exist in the database, the migration fails.

Expected behavior Add matching calls to HasIndex with the existing database names to the snapshot file like C# does.

simon-reynolds commented 3 years ago

Hi @LiteracyFanatic This should be resolved now in https://www.nuget.org/packages/EntityFrameworkCore.FSharp/5.0.3-beta004