-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Allow multiple indexes on the same properties #21089
Comments
Just want to record a limitation of this approach. (I do not think this limitation should change the approach mentioned above - I just want to record it). It will not be possible to define 2 "nameless" indexes (where "nameless" means that we do not assign a name at design time, and EF chooses the name when it needs to create the SQL CREATE INDEX statement) over the same properties which differ only in, for instance, the ASC/DESC or collation mentioned in #4050. So you if you were to do e.g. entityBuilder.HasIndex(listOfProperties);
entityBuilder.HasIndex(listOfProperties).HasAscendingDescending(listOfAscDesc); you would not be creating 2 different indexes, instead the 2nd line will update the 1st. This is what we do now for entityBuilder.HasIndex(listOfProperties, name1);
entityBuilder.HasIndex(listOfProperties, name2).HasAscendingDescending(listOfAscDesc); Also, since it is now part of the identifier of an Index, the name should be immutable. If we were doing this from scratch, I'd prefer to remove or Obsolete the Note: we'll also need to mention that: [Index("A", "B")]
public class SomeEntity { ... } followed by entityBuilderForSomeEntity.HasIndex(new List<Property>(A, B), "SomeIndexName"); will create 2 different indexes. |
Decisions from meeting 6/1/2020:
|
I noticed after upgrading a project to EF Core 5.0 from 3.1 today I suddenly had 500+ compiler warnings from old migrations. It would be nice if the framework did some minimal cleanup on old migrations. I ran this to fix them: var path = @"C:\Users\Me\Source\Repos\MyProject\Data\Migrations";
foreach (var file in Directory.EnumerateFiles(path, "*.Designer.cs"))
{
var filePath = Path.Combine(path, file);
Console.WriteLine($"Processing {filePath}...");
var contents = File.ReadAllLines(filePath).ToList();
var pragmaDisable = "#pragma warning disable 612, 618";
var pragmaRestore = "#pragma warning restore 612, 618";
if (!contents.Any(x => x.Contains(pragmaDisable)))
contents.Insert(contents.FindIndex(x => x.Contains("protected override void BuildTargetModel")) + 2, pragmaDisable);
if (!contents.Any(x => x.Contains(pragmaRestore)))
contents.Insert(contents.Count - 3, pragmaRestore);
File.WriteAllLines(filePath, contents, Encoding.UTF8);
} |
Currently the EF model identifies indexes by an ordered list of properties. This means that only a single index can be defined over that ordered list of properties. This issue is about changing this in the EF model so that indexes are identified by a name. This will allow multiple indexes to be defined over the same ordered list of properties, which in the turn will allow issues such as #4150 to be fixed.
The text was updated successfully, but these errors were encountered: