Jawaban Craig, meskipun tidak berfungsi apa adanya, membuat saya melihat ke arah yang benar. Ternyata ada properti EntityConnection.StoreConnection yang memberi Anda koneksi ke DBMS yang mendasarinya. Jadi mengeksekusi SQL "asli" semudah ini:
static void ExecuteSql(ObjectContext c, string sql)
{
var entityConnection = (System.Data.EntityClient.EntityConnection)c.Connection;
DbConnection conn = entityConnection.StoreConnection;
ConnectionState initialState = conn.State;
try
{
if (initialState != ConnectionState.Open)
conn.Open(); // open connection if not already open
using (DbCommand cmd = conn.CreateCommand())
{
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
}
finally
{
if (initialState != ConnectionState.Open)
conn.Close(); // only close connection if not initially open
}
}