找不到Connection.CreateConnectionScope(),命名空间是什么?解决思路
找不到Connection.CreateConnectionScope(),命名空间是什么?
提示:System.Data.Common.DbConnection 不包含 CreateConnectionScope
------解决方案--------------------
using Microsoft.Data.Extensions;
http://archive.msdn.microsoft.com/EFExtensions/Release/ProjectReleases.aspx?ReleaseId=3624
提示:System.Data.Common.DbConnection 不包含 CreateConnectionScope
- C# code
using (var dbtran = new TransactionScope(TransactionScopeOption.Required)) { using (var t= new TestEntities()) { using (t.Connection.CreateConnectionScope())// EF Extension中的扩展方法,作用是open connection并在dispose里释放它 { t.AddToTableA(t1); t.SaveChanges(); var cmd = t.CreateStoreCommand("update form set xxx=xxx where formid=2", CommandType.Text); cmd.ExcuteNonQuery(); dbtran.Complete(); } } }
------解决方案--------------------
using Microsoft.Data.Extensions;
http://archive.msdn.microsoft.com/EFExtensions/Release/ProjectReleases.aspx?ReleaseId=3624