开发者

Why is TransactionScope causing problems using Entity Framework?

I have a problem that I know is something local, related to transaction scope, probably MSDTC (I don't know very much about it).

The other project developer (same codebase, everything commited) executes the whole solution, but when I try to get some data from the database (not always), I have the following error:

The underlying provider failed on EnlistTransaction.


   at System.Data.EntityClient.EntityConnection.EnlistTransaction(Transaction transaction)
   at System.Data.Objects.ObjectContext.EnsureConnection()
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__0[TResult](IEnumerable`1 sequence)
   at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
   at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQuery开发者_运维百科Provider.Execute[S](Expression expression)
   at System.Linq.Queryable.First[TSource](IQueryable`1 source, Expression`1 predicate)

If I comment the using transaction scope, complete() and everything, it works as expected.

Have you ever had this problem before?

EDIT:

The query that throws this error is something very simple, like:

var entity = Entities.EntityX.First(p => p.ID == id);

EDIT, SOLVED:

Server's lmhosts was outdated.


Firewall rules blocking the DTC ports, maybe? Or an incomplete firewall rule allowing some DTC ports, but not others? I've never gotten distributed transactions to work well through a firewall. Even after following the directions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜