[英]The data area passed to a system call is too small when saving with C# EF6
我有一個 C#,Winforms EF6 應用程序。 數據庫是 SQL 服務器緊湊型 4。在某些計算機中(大多數工作正常)我在保存簡單的 object 時出現異常“傳遞給系統調用的數據區域太小”,如下面的代碼所示
public void Add(SimpleObject simpleObject)
{
try
{
using (var db = new MyDbContext())
{
db.SimpleObjects.AddOrUpdate(e => e.Description, simpleObject);
db.SaveChanges();
}
}
catch(Exception ex)
{
_logger.ErrorException("Add", ex);
throw;
}
}
SimpleObject 非常簡單,只有 2 列([ID] INT NOT NULL IDENTITY (1,1),[DESCRIPTION] NVARCHAR(4000))。 引發異常的實例在“描述”字段中具有通常保存在大多數計算機中的通用文本(低於 150 個字符)。 命令 AddOrUpdate 引發異常。
使用 NLog 記錄的完整異常詳細信息:
System.Data.Entity.Core.EntityCommandExecutionException:執行命令定義時出錯。 有關詳細信息,請參閱內部異常。 ---> System.Data.SqlServerCe.SqlCeException:傳遞給系統調用的數據區太小。 在 System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr) 在 System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan() 在 System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior 行為,字符串方法,ResultSetOptions 選項) 在 System.Data .Entity.SqlServerCompact.SqlCeMultiCommand.ExecuteReader(CommandBehavior 行為) 在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func
3 操作,TInterceptionContext 攔截上下文,Action3 executing, Action
3 執行)在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior 行為) ---內部異常堆棧跟蹤結束 --- 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreC System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) 在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T] 的命令(EntityCommand entityCommand,CommandBehavior 行為) ](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery
1.<>c__DisplayClass7.b__s.Object.Object.Object.在 System.Query1.b__sData.Entity1.GetResults(Nullable
1 forMergeOption) 在 System.Data.Entity.Core.Objects.ObjectQuery1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() at System.Data.Entity.Internal.LazyEnumerator
1.MoveNext () 在 System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](DbSet
1 source) at System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](DbSet
1 集,IEnumerable1 identifyingProperties, InternalSet
1 internalSet,TEntity[] 實體)在 System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](IDbSet1 set, Expression
1 identifierExpression,TEntity[] 實體)>
任何幫助將不勝感激!
You should upgrade to SQL CE 4.0 SP1, as it contains a fix for that issue - see http://erikej.blogspot.com/2012/03/sql-server-compact-40-sp1-ctp1.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.