Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityFramework Migration Generation Produces Unexpected Index Column Name #31153

Open
Mike-E-angelo opened this issue Jun 28, 2023 · 8 comments

Comments

@Mike-E-angelo
Copy link

File a bug

This is the continuation of the efforts of this issue:
#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

@ajcvickers
Copy link
Member

@Mike-E-angelo Unfortunately, due to bureaucracy, I currently don't have access to attachments submitted to the developer community. Once you have created a minimal repro, please attach it here so that we can investigate. Make sure it contains only the code needed to reproduce the issue. Please rip everything else out.

@Mike-E-angelo
Copy link
Author

Here you go @ajcvickers:

ConsoleApp2\Migrations\20230705133851_EFCore72.cs:62:

Expected (and what EFCore6 generates):

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

Actual:

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

ConsoleApp2.zip

Please let me know if there is any further information I can provide to further assist you.

@ajcvickers
Copy link
Member

Note for triage: I am able to reproduce this.

@Mike-E-angelo
Copy link
Author

Hi @ajcvickers any luck with this, by chance? I ran into it again with a recent migration. Thank you for any update that you can provide.

@ajcvickers
Copy link
Member

@Mike-E-angelo This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you.

@Mike-E-angelo
Copy link
Author

Understood @ajcvickers. Thank you for taking the time to update, and for working on the weekend. 🙏

@AndriySvyryd
Copy link
Member

This will likely be fixed by #9329

@Mike-E-angelo
Copy link
Author

What's interesting @AndriySvyryd is that this issue did not occur prior to .NET7. Columns were correctly identified and created without issue until this version. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants