Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 参数值';16375323027.987000000';超出范围_C#_Entity Framework_Sql Server 2008_Precision_Savechanges - Fatal编程技术网

C# 参数值';16375323027.987000000';超出范围

C# 参数值';16375323027.987000000';超出范围,c#,entity-framework,sql-server-2008,precision,savechanges,C#,Entity Framework,Sql Server 2008,Precision,Savechanges,我在尝试通过EntityFramework在db中保存值时遇到以下异常 InnerException: An error occurred while updating the entries. See the inner exception for details. InnerException -> InnerException: Parameter value '163753323027.987000000' is out of range. 我尝试了所有提供的解决方案。但仍然无法

我在尝试通过EntityFramework在db中保存值时遇到以下异常

InnerException: An error occurred while updating the entries. See the inner exception for details.
InnerException -> InnerException: Parameter value '163753323027.987000000' is out of range.
我尝试了所有提供的解决方案。但仍然无法解决问题。我正在使用EntityFramework,SQL Server。这不是代码优先

在我的表中有一列

ActualHydPressureDropPipe decimal(30, 10)
应用程序试图存储在数据库中的值为16375323027.987000000

我无法尝试这里提供的答案,因为我没有EntityTypeConfiguration类

我试着给出答案

模型创建时受保护的覆盖无效(DbModelBuilder modelBuilder)
{
modelBuilder.Entity().Property(x=>x.actualhydpressedroppipe).HasPrecision(30,10);
基于模型创建(modelBuilder);
}
这也不行。我不知道为什么控件没有进入上述方法。可能是因为这不是代码优先

我登记了我的edmx我有

<Property Type="Decimal" Name="ActualHydPressureDropPipe" Nullable="false" Precision="30" Scale="10" />


请指教。

我什么都试过了。我试着提高精度和射程。。但这个问题仍然存在。有趣的是,一旦我重新启动VisualStudio,它就会自动得到解决


奇怪。但有时有些事情只需要重新启动就可以自行修复。

我也遇到了类似的问题。当写入十进制数(18,0)时,我的错误消息是: 参数值“0.7880523731587561374795417349”超出范围

我用重启VS尝试了上述解决方案,但没有成功。但是,添加舍入解决了我的问题:

Math.Round((0.7880523731587561374795417349m), 4)

有趣的是,这是有效的,即使实际上十进制(18,0)在小数点后也不存储任何数字。它应该是十进制(18,4)以正确保存四舍五入的数字。

试试16375323027,也许这会告诉你一些原因。
Math.Round((0.7880523731587561374795417349m), 4)