I believe the problem is caused by way LinqPad is creating the DBContext (or whatever it does internally) when you query a database directly (as opposed to creating your own EF connection). If I run this:
using (var context = new MyContext()) {
var query =
from x in context.MyTable
select new {
x.ID,
g = Guid.NewGuid()
};
}
I get the following SQL
SELECT
[Extent1].[ID] AS [ID],
NEWID() AS [C1]
FROM [dbo].[MyTable] AS [Extent1]
Which results in a unique guid for each row. You can alter the Linq to orderby Guid.NewGuid()
and you'll get the random sorting that you want.
var query =
from x in context.MyTable
orderby Guid.NewGuid()
select new {
x.ID
};