关于网友提出的“ An error occurred while starting a transaction on the provider connection”问题疑问,本网通过在网上对“ An error occurred while starting a transaction on the provider connection”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: An error occurred while starting a transaction on the provider connection
描述:EFtransaction
An error occurred while starting a transaction on the provider connection. See the inner exception for details.
at System.Data.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel) at System.Data.EntityClient.EntityConnection.BeginTransaction() at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at OMIS.Data.EfRepository`1.Insert(T entity) at OMIS.Services.TaskPlans.TaskPlanService.GenerationTaskImplementForDevice(TaskPlan taskPlan, TaskImplement taskImplement, IEnumerable`1 patrolStandardInfoList, IEnumerable`1 taskPlanDeviceMeasureParameters, TaskPlanDevice taskPlanDevice)
代码如下:
foreach (PatrolStandardInfo oldPatrolStandardInfo in oldPatrolStandardInfos)
{
if (!oldPatrolStandardInfo.IsDeleted)
{
int versionFlag = 0;
foreach (StandardInfoVersion oldVersion2 in oldPatrolStandardInfo.Versions)
{
try
{
if (!oldVersion2.IsDeleted)
{
if (versionFlag == 0)
{
patrolStandardInfo = new PatrolStandardInfo();
patrolStandardInfo.Type = (short)PatrolStandardType.TaskImplement.GetHashCode();
patrolStandardInfo.TypeId = taskImplementDevice.Id;
patrolStandardInfo.ParentId = oldPatrolStandardInfo.Id;
patrolStandardInfo.StandardType = oldPatrolStandardInfo.StandardType;
_patrolStandardInfoRepository.Insert(patrolStandardInfo);
}
standardInfoVersion = new StandardInfoVersion();
standardInfoVersion.PatrolStandardInfoId = patrolStandardInfo.Id;
standardInfoVersion.StandardInfoId = oldVersion2.StandardInfoId;
_standardInfoVersionRepository.Insert(standardInfoVersion);
versionFlag++;
}
}
catch (Exception ex)
{
string sql = string.Format("Insert into Trace(ExceptionMsg,TraceLog) values ('{0}','{1}')", "GenerationTaskImplementForDevice" + ex.Message.Replace("'", "''"), ex.StackTrace.Replace("'", "''"));
DBHelper.Conn.ExecuteSql(sql);
throw ex;
}
}
}
}
这个是什么原因导致的呢?请教高手,谢谢。
解决方案1: See the inner exception for details
以上介绍了“ An error occurred while starting a transaction on the provider connection”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1858257.html