How can f System.Data.Entity.Internal.InternalContext.SaveCh

本文关键字:Internal InternalContext SaveCh Entity Data can System How | 更新日期: 2023-09-27 18:10:48

我有一个调用Web服务的windows服务,然后将信息存储在我的t-sql数据库中。在我的pc上此服务工作,但在另一台具有相同数据库的pc上,我有此错误:

[16:06:00] Teresa Gabriele: Errore saveLocalActivity:    in System.Data.Entity.Internal.InternalContext.SaveChanges()
   in System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   in System.Data.Entity.DbContext.SaveChanges()
   in GestoreService.Manager.Impl.AttivitaManagerImpl.saveLocalActivity(LOCAL_PE_Attivita attivita, Boolean saving) in c:'Users'michele.castriotta'Source'Workspaces'Omniacare'software'exercise platform'GestoreService'GestoreService'Manager'Impl'AttivitaManagerImpl.cs:riga 25
[16:06:52] Teresa Gabriele: Errore isAttivitaXMedicoExist:    in System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   in System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   in System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   in System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   in System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   in System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
   in System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   in System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)
   in System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
   in System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
   in System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass57.<ExecuteStoreCommand>b__56()
   in System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   in System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass57.<ExecuteStoreCommand>b__55()
   in System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   in System.Data.Entity.Core.Objects.ObjectContext.ExecuteStoreCommand(TransactionalBehavior transactionalBehavior, String commandText, Object[] parameters)
   in System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
   in System.Data.Entity.Database.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)
   in System.Data.Entity.Database.ExecuteSqlCommand(String sql, Object[] parameters)
   in GestoreService.Manager.Impl.AttivitaManagerImpl.inserAttivitaXMedico(Int32 idAttivita, String codiceFiscaleOperatoreMedico, String username) in c:'Users'michele.castriotta'Source'Workspaces'Omniacare'software'exercise platform'GestoreService'GestoreService'Manager'Impl'AttivitaManagerImpl.cs:riga 192

这是代码:

 _db.LOCAL_PE_Attivita.Add(attivita);
int result = _db.SaveChanges(); //LINE 25
if (result > 0)
return true;

How can f System.Data.Entity.Internal.InternalContext.SaveCh

问题不清楚,但我认为错误不在代码中。日志告诉错误是在保存数据库,但如果这个应用程序只在你的电脑上工作,我认为(可能)与不同版本的数据库有关。

检查是否有问题