I've got some code which is throwing an exception when I use this against SqlServer CE 4.0 & within a TransactionScope. First, the code, then the error.
// Arrange.
// ... some stuff ...
// like .. order = get order with ID #1.
// Act.
using (new TransactionScope())
{
order.Name = name; // Update a field.
_orderRepository.Save(order);
_unitOfWork.Commit(); // <-- this works 100% fine.
// Assert.
// Reload the order so we can see if the data persisted to the DB.
var updatedOrder = _orderRepository
.Find()
.Where(x => x.OrderId == 1)
.SingleOrDefault(); <-- // this throws the exception.
Assert.IsNotNull(updatedOrder);
Assert.AreEqual(name, order.Name);
}
The exception error is:-
System.Data.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: The connection object can not be enlisted in transaction scope.
So the first save/commit works fine but when I try to retrieve the object again (to see if the data persisted in the transaction) that's when the error occurs.
Now i'm sure this is a Single Transaction and not a Distributed Transaction ... so I'm assuming this should just work?
Suggestions, kind folk?