I would like to define an index in the EF modelbuilder which has an included column.
I can add columns which are part of the index like this (Via the index annotation):
base.Property(x => x.Col1).HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(
new IndexAttribute("IX_MyIndex", 1) { IsUnique = false, IsClustered = false }));
base.Property(x => x.Col2).HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(
new IndexAttribute("IX_MyIndex", 2) { IsUnique = false, IsClustered = false }));
but I want to generate something like the following:
CREATE NONCLUSTERED INDEX [MyIndex] ON [MyTable]
(
[Col1] ASC
)
INCLUDE ([Col2])