Entity Framework 6 migrations: first create an index with enabled column code

I am looking for a way to create such an index using Entity Framework 6.1:

 CREATE INDEX [IX_MYINDEX] ON [db].[dbo].[Payments] ([IsDeleted])
 INCLUDE ([Id], [InvoiceId], [OrderId])

I found several other answers that say that this cannot be done because of the Include columns, but all these answers are from 3 years ago, so I wonder if something has been added that would make this possible.

We would like to avoid (if at all possible) the presence of real SQL in our code and prefer the real first code solution, in which we comment on class classes. I tried Googling for this, and I spent some time reading different answers on Stackoverflow, but didn't seem to find it needed. Can someone point me in the right direction?

Many thanks

+4
source share
2 answers

Not sure if this can be done with data annotations, but you can create an EF migration :

CreateIndex("dbo.Payments", new[] {"IsDeleted", "Id", "InvoiceId", "OrderId"}, name: "IX_MYINDEX");
0
source

No, still not possible in EF6 and EF Core

0
source

Source: https://habr.com/ru/post/1678325/


All Articles