Indexing is a common concept across multiple data stores. Although their implementation in a data store can vary, they can also be used for column-based lookups (or a set of columns) to be more efficient.
The hyperlink login is visible.
What to know:
In Entity Framework 6, you can add indexes by adding attributes to fields, but in ef core, you cannot use attributes to add indexes to table fields, so you must rewrite the OnModelCreating method and write the corresponding rules one by one in it.
Different tables need to be written in this method, which is not easy to maintain and the readability is too poor, so we write the index of each table in our own method to facilitate updates and searches.
ef core is usedcode fristSchema creates a table structure.
First, create a new IOnModelCreate interface, the code is as follows:
We define an object at the bottom of the class class of different tables and inherit the interface, for example:
AccountSetting Code:
EmailSentHistorySetting code:
In your own DbContext context object, rewrite the OnModelCreating method, use the reflection method, and execute the OnModelCreating method in turn to create indexes, relationships, data seeding, etc.
The OnModelCreating method is as follows:
Execute the Create Migration command to generate the following code:
Discovery, indexes can be successfully created through reflection methods, etc.
(End)
|