在我的开发盒(Windows7 64位)上一切正常,我能够检索记录和保存记录。
当我部署到Windows Server2008 (32位)机器上时,我能够很好地检索数据并查看它。当我执行以下任一操作时,问题就出现了:
1)尝试保存:
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.ArgumentException: The specified value is not an instance of type 'Edm.Decimal'
Parameter name: value
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.ValidateConstant(TypeUsage constantType, Object value)
at System.Data.Mapping.Update.Internal.UpdateCompiler.GenerateValueExpression(EdmProperty property, PropagatorResult value)
at System.Data.Mapping.Update.Internal.UpdateCompiler.BuildPredicate(DbExpressionBinding target, PropagatorResult referenceRow, PropagatorResult current, TableChangeProcessor processor, Boolean& rowMustBeTouched)
at System.Data.Mapping.Update.Internal.UpdateCompiler.BuildUpdateCommand(PropagatorResult oldRow, PropagatorResult newRow, TableChangeProcessor processor)
at System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler)
--- End of inner exception stack trace ---
at System.Data.Mapping.Update.Internal.TableChangeProcessor.CompileCommands(ChangeNode changeNode, UpdateCompiler compiler)
at System.Data.Mapping.Update.Internal.UpdateTranslator.<ProduceDynamicCommands>d__0.MoveNext()
at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()
at System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator)
at System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands()
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.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at Dashboard.Data.Repository.RepositoryBase`2.OnCompleteSave()2)或尝试检索序列中的下一个数字:
System.InvalidOperationException: The specified cast from a materialized 'System.Decimal' type to the 'System.Int64' type is not valid.
at System.Data.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Dashboard.Data.DashboardDbContext.ExecuteScalar[TResult](String query, Object[] parameters) in c:\Builds\1\Exploration Archives\Dashboard (MAIN) (talus test)\Sources\Exploration Archives\Dashboard\Main\Dashboard.Data\Dashboard.contrib.cs:line 23
at Dashboard.Data.Repository.RepositoryBase`2.GetNextIdFromSequence()最让我困惑的部分是,在部署到Windows Server 2008计算机后,事情部分地工作(我能够检索数据),但只有当我试图从序列中检索或保存时,它才会崩溃。
你知道是什么原因造成的吗?
发布于 2012-12-12 03:32:41
找到问题所在。
对于我的ID列,在我的.NET对象上,我使用了数据类型long,以及对应的oracle数据类型number。在我的机器上运行得很好。基于对此问题的其他研究,我尝试将oracle数据类型更改为number(19)。还是不能走。
看起来long的支持充其量也是不可靠的。我必须将.NET对象的数据类型更改为int,并将oracle数据类型更改为int。这起作用了。
最困扰我的部分是,它显然将number和number(19)视为decimal数据类型,并且它为我进行到long的缩小转换没有问题。这个问题是在我尝试保存的时候才出现的,我做了一个从long到decimal的非缩小转换。去想一想。
发布于 2014-05-06 06:51:43
在这里添加注释以供将来参考,因为此问题也会影响Mysql驱动程序- EntityFramework v6和MySql.Data.Entities.6.8.3.0。无符号bigint db列会导致此问题。
"id BIGINT(20) UNSIGNED“导致”指定值不是有效常量类型的实例。参数名称: type“异常。更改关联的类属性ulong无济于事。正在将数据库列"id BIGINT(20)“绑定到...
[Key]
[Column("id")]
public long Id { get; set; }...works很好。
https://stackoverflow.com/questions/13826444
复制相似问题