dotnet / dotnet/efcore

EntityFramework Migration Generation Produces Unexpected Index Column Name

Open
#31,153 8 comments 2 reactions 0 assignees View on GitHub
area-model-building customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

## File a bug

This is the continuation of the efforts of this issue:
https://github.com/dotnet/efcore/issues/29847

I have uploaded an SLN which contains the generated migration here:
https://developercommunity.visualstudio.com/t/EntityFramework-Migration-Generation-Pro/10402954

After removing the offending indexes and running the following command in Visual Studio’s Developer PowerShell:

```
dotnet ef migrations add EFCore72 -v --project Starbeam.Applications.Gateway.Initialization --startup-project Starbeam.Entities.Design --configuration Debug

```

It produces the `20230628141213_EFCore72.cs` migration file which contains the following command:

```
migrationBuilder.CreateIndex(
name: "IX_Transaction_SystemDebit_SourceId",
table: "Transaction",
column: "SystemDebit_SourceId",
unique: true,
filter: "[SourceId] IS NOT NULL");

```

Expected (this is what is produced in .NET6):

```
migrationBuilder.CreateIndex(
name: "IX_Transaction_SystemDebit_SourceId",
table: "Transaction",
column: "SystemDebit_SourceId",
unique: true,
filter: "[SystemDebit_SourceId] IS NOT NULL");

```

Please do let me know if there is any further information that I can provide and I will assist. Please also let me know if I have fundamentally misunderstood something as this is always a valid possibility with me. :)

### Include provider and version information

EF Core version: 7.0.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: net7.0
Operating system: Windows 10
IDE: Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.7.0 Preview 2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.