.NET / Entity Framework - System.Data.UpdateException 不够精确?
我陷入了一个使用实体框架和 MS SQL Server 2005 的小型 .NET 迁移项目中。当持久保存不适合数据库模式的数据时(例如,字符串太长),我收到了 System.Data 异常。 UpdateException 表示“字符串或二进制数据将被截断”。但没有任何信息涉及到哪个领域。有人知道如何得到这个吗?
谢谢
这里的堆栈跟踪:
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
at HAM.Inventory.Data.Repository.DocumentRepository.Save(Document document) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.Data\Repository\DocumentRepository.cs:line 177
at HAM.Inventory.Business.Managers.DocumentManager.Save(Document document) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.Business\Managers\DocumentManager.cs:line 75
at HAM.Inventory.MigrationClient.Common.Migration.SaveItem(ItemBase item) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.MigrationClient\Common\Migration.cs:line 143
at HAM.Inventory.MigrationClient.Common.Migration.SaveAndClearItems(List`1 items) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.MigrationClient\Common\Migration.cs:line 76
和内部异常:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
i got thrown into a small .NET migration project that is using the Entity Framework and MS SQL Server 2005. when persisting data that is not working with db schema (e.g. a string is too long), I am getting an exception System.Data.UpdateException that says "String or binary data would be truncated". But there is no information to which field it relates. does someone has a clue how to get this?
thx
here the stacktrace:
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Objects.ObjectContext.SaveChanges()
at HAM.Inventory.Data.Repository.DocumentRepository.Save(Document document) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.Data\Repository\DocumentRepository.cs:line 177
at HAM.Inventory.Business.Managers.DocumentManager.Save(Document document) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.Business\Managers\DocumentManager.cs:line 75
at HAM.Inventory.MigrationClient.Common.Migration.SaveItem(ItemBase item) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.MigrationClient\Common\Migration.cs:line 143
at HAM.Inventory.MigrationClient.Common.Migration.SaveAndClearItems(List`1 items) in D:\ludewigg\Documents\Projects\HAM\src\VBS-HAM-Inventory\Main\HAM.Inventory.MigrationClient\Common\Migration.cs:line 76
and the inner exception:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看
StateEntries
属性。它应该包含所有失败的对象。Look at the
StateEntries
property. It should have all the failing objects.