title: Random order with Entity Framework and MySQL
body: <p><strong>Summary:</strong> I want to find a way to make random order with Entity Framework and MySQL (that's important). That solution shouldn't use raw sql queries or ordering AFTER loading all values from database.</p>
  
  <p><strong>What I've tried:</strong></p>
  
  <p>I took idea about using NewGuid() for random order from <a href="https://stackoverflow.com/a/4120132/596207">that answer</a>.</p>
  
  <p>Code:</p>
  
  <pre><code>var query = from e in context.Table
  orderby Guid.NewGuid()
  select e;
  var test = query.FirstOrDefault();
  </code></pre>
  
  <p>Always thrown exception:</p>
  
  <pre><code>An error occurred while executing the command definition. See the inner exception for details.
  Inner exception:
  FUNCTION MyDatabase.NewGuid does not exist System.Exception {MySql.Data.MySqlClient.MySqlException}
  </code></pre>
  
  <p>Seems that problem is that MySQL doesn't have function NewGuid().</p>
  
  <p>How can I order by MySQL function <code>RAND()</code> instead of <code>NewGuid()</code>. In other words, how to use custom function <code>RAND</code> in Entity Framework?</p>