Hi folks,
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 ...
// Act.
using (new TransactionScope())
{
order.Name = name;
_orderRepository.Save(order);
_unitOfWork.Commit(); // <-- this works 100% fine.
// Assert.
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. I can see the data getting passed across to the db, using EFProf as the profiler...
enlisted object context in distributed transaction with isolation level: Serializable
insert [Orders]
([Name],
[CreatedOn],
[SentOn],
[UserId])
values('New Order Name - Pew Pew Pew' /* @0 */,
'2011-01-20T16:30:00.00' /* @1 */,
null,
1 /* @2 */)
select [OrderId]
from [Orders]
where [OrderId] = @@IDENTITY
rollback transaction
So it failed to pass ANY data across the wire for the 2nd database request (ie. the updatedOrder code), to the sdf ... which is why there's no 2nd select statement there. And of course, the rollback will be called because the transaction failed to end with
a commit.
Can someone help me out here?
-Pure Krome-
View Complete Post