Service Broker with Entity Framework 6


I've got a Windows service that uses a Service Broker queue to get notifications that some processing is needed:

var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["MathsEngine.Properties.Settings.TargetConnectionString"].ToString());

var cmd = new SqlCommand("WAITFOR ( RECEIVE * FROM dbo.MathsEngineQueue);", cnn) {CommandTimeout = 0};


// Execute the command - we will wait here until a new entry appears in the Notification Queue
SqlDataReader reader = cmd.ExecuteReader();

// Get the message text from the reader
while (reader.Read())
    // Get the message body text and convert into a legible format
    _messageText = Encoding.Unicode.GetString(reader.GetSqlBinary(reader.GetOrdinal("message_body")).Value);


I'm now starting to use Entity Framework 6.0 to do all my db interactions. I've been trying to find a way to monitor the queue and get any messages via EF. So far the only partial answers I've found involve very convoluted use of SQLDependency which still doesn't let me get messages out of the queue.

Is there actually a way of doing this in EF or am I stuck for now having this one area unchanged?

Agree to @Rob. I've spent fair bit amount of time to figure out this issue as well and got it concluded that Service Broker (SB) won't get along with Entity Framework 6 (mine is 6.1.1) at this stage. All unit tests (with LocalDB, actually) I created, using EF without SB, were successful but, once they are integrated with SB, they won't work.

To clarify more, SELECT statements work but INSERT, UPDATE and DELETE won't change anything.