1

In EF Fluent API we can create Indexes using

// In earlier versions
HasIndex(t => t.OccurrenceDate).IsUnique(false);

OR

// In older versions
Property(t => t.OccurrenceDate)
        .HasColumnAnnotation(IndexAnnotation.AnnotationName,
                             new IndexAnnotation(new IndexAttribute("IX_OccurrenceDate") {
                                     IsUnique = true,
                             }));

The question is how can I specify ASC/DESC attributes to created index?

amiry jd
  • 27,021
  • 30
  • 116
  • 215
  • "earlier" and "older" tend to be synonyms when talking about software versions. You may want to revisit the comments above each sample. – Damien_The_Unbeliever Dec 11 '18 at 11:46
  • This might help you => https://stackoverflow.com/questions/29922099/how-to-add-an-index-on-multiple-columns-with-asc-desc-sort-using-the-fluent-api – er-sho Dec 11 '18 at 11:47
  • According to : https://github.com/jsakamoto/EntityFrameworkCore.IndexAttribute/issues/1 it's not possible via FluentApi. If you use db migrations you can add sql script that will create index for you. – Szymon Tomczyk Dec 11 '18 at 11:51

0 Answers0