SQL generated by EntityFramework StartsWith() contains plan altering ESCAPE '~' (tilde)

Viewed 5457

Using EntityFramework, the clause .OrderBy(x => x.Title.StartsWith("foo")) results in the SQL WHERE (Title LIKE 'foo%' ESCAPE '~').

Looking at the execution plan for the full query I see that I get a different plan (one making use of the column's non clustered index) when I remove the ESCAPE '~'.

Why is EF trying to escape a string which doesn't need it, and how can I make it stop?

2 Answers
Related