dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.79k stars 3.19k forks source link

config drop existing #34683

Closed NasserFallahzadeh closed 1 month ago

NasserFallahzadeh commented 2 months ago

Please add feature that can config DROP_EXISTING index option using fluent API.

roji commented 2 months ago

Can you provide more context on why you need this? We have #20692 tracking adding ALTER INDEX support, but even without it, EF's migrations mechanism already drops and recreates the index if it's modified. In which situations would this be useful with EF?

AndriySvyryd commented 1 month ago

EF Team Triage: This issue is lacking enough information for us to be able to effectively triage it. In particular, it is missing the following information requested in the new issue template. Can you please provide this information?

Steps to reproduce

Ideally include a complete code listing that we can run to reproduce the issue.

Alternatively, you can provide a project/solution that we can run.

BTW we're not just doing this to be mean :smile:... we get a lot traffic on this project and it takes time to attempt to reproduce an issue based on fragments of information. In addition, our attempt is often unsuccessful as the exact conditions required to hit the issue are often not explicitly included in the code provided. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we ask that folks give us a self-contained way to reproduce an issue.

For a guide on submitting good bug reports, read Painless Bug Tracking.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

NasserFallahzadeh commented 6 days ago

I performed a performance tuning assessment using SQL Server Management for my database, and it provided suggestions for adding specific indexes. One of the settings for an index was that DROP_EXISTING was set to OFF. I need this capability in the Fluent API to configure these settings.

roji commented 6 days ago

DROP_EXISTING already defaults to OFF, so there's no need for you to explicitly specify it; SSMS is just producing a very verbose suggestion here.

The point of DROP_EXISTING is to be able to specify ON, for cases where you need to recreate an existing index, the recreation process would take a long time, and you want queries to continue using the old index in the meantime. I've opened #35067 to track making use of this in EF, but this is going to help only in very few cases, so it's unlikely we'll do this any time soon (support for ALTER INDEX is much more important example, #20692).