EF IndexAnnotation included

I would like to define an index in EF modelbuilder that has an included column.

I can add columns that are part of an 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])

      

+3
c # entity-framework entity-framework-6 ef-migrations


source to share


No one has answered this question yet

See similar questions:

87
How to create an index in Entity Framework 6.2 with first code

or similar:

201
Null or standard common argument comparison in C #
31
Create Unique Index with Entity Framework 6.1 API
6
Asp.net Core Entity Framework cannot find IndexAttribute
4
A migration created that already matches the schema
3
Preventing EF Code First From Inheriting Indexes in TPT
2
EF Code First - Multiple Index Column with Navigation Property
2
First code migrations: annotate the entire database?
1
Entity Framework 6 Filtered Index
0
Retrieving user defined 'combination of columns' from database using Entity Framework
0
How to select T-SQL into C # variables



All Articles
Loading...
X
Show
Funny
Dev
Pics