See docs
Help translating "CREATE INDEX" to Data Annotations
Hello everybody,
How can I translate something like this
CREATE INDEX [missing_index_10_9_WATravelUsers] ON [WATravelUsers] ([UserId]) INCLUDE ([TravelId]) WITH(FILLFACTOR=70)
into data annotations in EF6?
Thanks!
2 answers
Sort by: Most helpful
-
-
Lan Huang-MSFT 29,171 Reputation points Microsoft Vendor
2022-09-19T05:14:51.717+00:00 Hi @Stesvis ,
You can check out the documentation below:
https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/data-annotations
This article will focus on using DataAnnotations (in the System.ComponentModel.DataAnnotations namespace) to configure your classes.You can create an index on one or more columns using the IndexAttribute. Adding the attribute to one or more properties will cause EF to create the corresponding index in the database when it creates the database, or scaffold the corresponding CreateIndex calls if you are using Code First Migrations.
Note:EF6.1 Onwards Only
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.