Parameter value '163753323027.987000000' is out of range

4.9k views Asked by At

I am getting the following Exception while trying to save a value in db via EntityFramework

InnerException: An error occurred while updating the entries. See the inner exception for details.
InnerException -> InnerException: Parameter value '163753323027.987000000' is out of range.

I tried all the solutions provided. But still unable to resolve the issue. I am using EntityFramework, SQL Server. This is not code-first.

In my table I have a column

ActualHydPressureDropPipe decimal(30, 10)

The value application is attempting to store in the db is 163753323027.987000000

I can not try the answer provided here here because I donot have EntityTypeConfiguration class.

I tried the answer give here

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
  modelBuilder.Entity<Mud_Volumes>().Property(x => x.ActualHydPressureDropPipe).HasPrecision(30, 10);
  base.OnModelCreating(modelBuilder);
}

This is not working either. I am not sure why the control is not entering into the above method. May be because this is not code first.

I checked in my edmx I have

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

Please advice.

2

There are 2 answers

0
Rama Kathare On BEST ANSWER

I tried everything. I tried increasing the Precision and Range.. But the issue still persisted. Funny thing is It automatically got solved once I restarted my Visual Studio.

Strange. But some times some things just need a restart to fix themselves.

0
Peter Huber On

I had a similar problem. When writing to a decimal(18,0), my error message was: Parameter value '0.7880523731587561374795417349' is out of range.

I tried the solution above with restarting VS, but no luck. However, adding rounding solved my problem:

Math.Round((0.7880523731587561374795417349m), 4)

Funny enough, this worked, even actually decimal(18,0) doesn't store any digit after the decimal point. It should be decimal(18,4) to save the rounded figure properly.