0

I have a recommendation from Azure to create the following index:

CREATE NONCLUSTERED INDEX [nci_wi_Transactions_71EA7D20388C3F47A9B9EBF2A1C7BA0C] ON [dbo].[Transactions] ([Client_Id]) INCLUDE ([Date], [Description], [Size], [Type]) WITH (ONLINE = ON)

Is it possible to execute this SQL directly from MSSQL without affecting my applications work? Or do I need to apply some migrations from code-first to keep database context with the correct state anyway?

3
  • Wouldn't matter unless you create the database from scratch via migrations. Otherwise, add it in: stackoverflow.com/questions/21192603/… Commented Jan 31, 2022 at 15:27
  • @SteveGreene, all database objects are created from code-first (using update-database). Your link explains how to create an index from code-first code, when my question is: is it possible to avoid this and create directly from MSSQL? Commented Feb 2, 2022 at 9:05
  • 1
    No, you don't need it in EF for the app to keep working or to realize the performance gain - although WHERE clause would be key for index use. Indices are behind the scenes at the SQL level. If you recreate the database from scratch, those objects won't be there unless you maintain a post creation script of some kind or do a schema compare. Commented Feb 2, 2022 at 15:36

1 Answer 1

0

Actually, @Steve in comment answered and I checked in runtime and Yes, it is safe to create an index directly from a database, which will not affect applications, used not changed DbContext.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.