title: EF Core MySQL Contains(variable) like operator
body: <p>I am using ASP.NET Web API Core with EF Core to create a method, which returns JSON format records.<br />
  When I use <strong>contains</strong> for <strong>like operator (%varible%)</strong>, an error occured with message below:</p>
  <blockquote>
  <p>An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code</p>
  <p>Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+ '%'</p>
  <p>ORDER BY <code>p</code>.<code>StoreId</code>, <code>p</code>.<code>CategoryId</code>' at line 4</p>
  </blockquote>
  <p>Seems one of <strong>%</strong> symbol is not at right position.<br />
  I checked my codes and raw sql output but didn't see any problem.<br />
  <strong>Hope someone can help me!</strong></p>
  <pre><code>var query = from p in db.Products
              join c in db.ProductCategory
                     on new { p.StoreId, p.CategoryId } equals new { c.StoreId, c.CategoryId } into pc
              from c in pc.DefaultIfEmpty()
              where (p.ProductName.Contains(&quot;a&quot;))
              select p;  
  
  query.ToList()
  </code></pre>
  <p><strong>Raw SQL</strong></p>
  <pre><code>SELECT `p`.`StoreId`, `p`.`ProductId`, `p`.`CategoryId`, `p`.`Description`, `p`.`ImagePath`, `p`.`ProductName`, `p`.`SalesPeriodFrom`, `p`.`SalesPeriodNeverEnd`, `p`.`SalesPeriodTo`, `p`.`SalesUnit`, `p`.`UnitPrice`, `c`.`StoreId`, `c`.`CategoryId`, `c`.`CategoryName`
  FROM `Products` AS `p`
  LEFT JOIN `ProductCategory` AS `c` ON (`p`.`StoreId` = `c`.`StoreId`) AND (`p`.`CategoryId` = `c`.`CategoryId`)
  WHERE `p`.`ProductName` LIKE ('%' + 'a') + '%'
  ORDER BY `p`.`StoreId`, `p`.`CategoryId`
  </code></pre>
  <p>Windows 7 Professional x64<br />
  Visual Studio 2015 Professional<br />
  MySQL 5.6.17</p>
  <p>Microsoft .NET Core 1.0.1<br />
  with dependencies</p>
  <pre><code>   &quot;Microsoft.ApplicationInsights.AspNetCore&quot;: &quot;1.0.2&quot;,
     &quot;Microsoft.AspNetCore.Mvc&quot;: &quot;1.0.1&quot;,
     &quot;Microsoft.AspNetCore.Routing&quot;: &quot;1.0.1&quot;,
     &quot;Microsoft.AspNetCore.Server.IISIntegration&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.AspNetCore.Server.Kestrel&quot;: &quot;1.0.1&quot;,
     &quot;Microsoft.Extensions.Configuration.EnvironmentVariables&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Configuration.FileExtensions&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Configuration.Json&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Logging&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Logging.Console&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Logging.Debug&quot;: &quot;1.0.0&quot;,
     &quot;Microsoft.Extensions.Options.ConfigurationExtensions&quot;: &quot;1.0.0&quot;,
     &quot;MySql.Data.EntityFrameworkCore&quot;: &quot;7.0.5-IR21&quot;,
     &quot;System.Linq.Dynamic.Core&quot;: &quot;1.0.6.6&quot;
  </code></pre>