Is there a way to create an index in MS SQL Server database using Entity Framework Code First Migrations, if the index has to be:
- descending by at least one column
- including other columns
It has to produce something like this:
CREATE NONCLUSTERED INDEX [IX_IndexName] ON [dbo].[TableName]
(
[Column1] ASC,
[Column2] DESC
)
INCLUDE ([Column3], [Column4])
I found an article on this very topic, but it offers quite a cumbersome solution. Possibly, something has improved since the time the article was written.
I am also aware of an ability to make my migration execute arbitrary SQL code, but I really want to be able to use some version of CreateIndex
method which does all the dirty work for me instead of writing SQL code myself.