我想在 TransactionScope 中包装一些 Entity Framework db I/o。一般来说,它工作正常。但是:我有一些情况基本上是这样的:
using (var tx=new TransactionScope())
{
using (var cx=new MyDbcontext())
{
var myrecord=cx.somerecorord.find(someid);
if (Roles.IsUserInRole(username, "admin"))
DoAdminThing(myrecord);
else
DoNonAdminThing(myrecord);
cx.SaveChanges();
}
}
这在 Roles.IsUserInRole 上以“提供者没有返回 ProviderManifestToken 字符串”而爆炸。
它似乎不喜欢在 EF TransactionScope 中执行 asp.net 安全数据库 I/o。有没有办法解决?
我真的真的不想在交易之前将角色的东西移到。这将需要打破逻辑上挂在一起的功能。