From the course: Using Entity Framework Core with Legacy Databases
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Adding and altering indexes
From the course: Using Entity Framework Core with Legacy Databases
Adding and altering indexes
- [Instructor] Indexes are invaluable when looking up data in a database that is of any significant size. While most existing databases have some indexes already set up it is common to find a query that is relatively inefficient and significant improvement could be added with a new index. Let's look at some ways that we can handle indexes in Entity Framework Core. By convention indexes are automatically created for each property or property group that compose a foreign key. Let's look at the indexes that we already have on the order table. Under the Model folders we'll open the context and scroll down to the orders table. We can see on the order table that we have an index for the order date. We also have indexes on the foreign keys for the table by convention. The customer ID and the salesperson ID both have indexes defined by convention. Let's look at the snapshot file in the migrations folder to see these indexes defined explicitly. We'll scroll down to the definition of the orders…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.