Adding index to a table
问题 I have a table Person : id, name I often have queries like: select * from Person where name Like "%abc%". I have 2 questions: How do I implement this query using code-first 5 (CTP5) How do I add an index on the name column to make data retrieval faster based on name like in the query? 回答1: Like operator can be performed with Contains function: var query = from p in context.Persons where p.Name.Contains("abc") select p; Index must be added by SQL - there is no special construction in EF to