Issue: (With Sql 2005)
I have been able to solve very similar problem using this code fragment:
var connection = new EntityConnection("name=MyEntities");
connection.Open();
var tran = connection.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
try
{
var dataContext = new MyEntities(connection);
//CRUD operation1
//CRUD operation2
//CRUD operation3 ...
Assert.AreEqual(expected, actual);
}
catch
{
throw;
}
finally
{
tran.Rollback();
connection.Close();
}
Where MyEntities is the EF DataModel.
The crucial part is the setting of the transaction: System.Data.IsolationLevel.ReadUncommitted.
Using this isolation level SQL queries can read you changes done inside the transaction.
Also you need to explicitly create a connection as I do on the first and second line.
I couldn't make it work using TransactionScope unfortunately.