Entity framework 如果存在';调用其范围内的asp.net安全性
我想在TransactionScope中包装一些实体框架db I/o。总的来说,它工作得很好。但是:我有一些案例基本上是这样的:Entity framework 如果存在';调用其范围内的asp.net安全性,entity-framework,transactions,Entity Framework,Transactions,我想在TransactionScope中包装一些实体框架db I/o。总的来说,它工作得很好。但是:我有一些案例基本上是这样的: using (var tx=new TransactionScope()) { using (var cx=new MyDbcontext()) { var myrecord=cx.somerecorord.find(someid); if (Roles.IsUserInRole(username, "admin")) DoAdmi
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。这有什么办法吗
我真的不想在交易之前把角色转移到其他地方。这需要将逻辑上连接在一起的函数分解成若干部分。Hmm您能检查一下您得到的函数是否存在内部异常吗?TransactionScope应该可以跨多个数据库正常工作。