-2
I am trying to save the value 137421,20 in a table of Sqlserver with a field of type Numeric(8,2). However I get an error with the description:
"Parameter value 137421,20 is out of range."
I’m trying to insert the value into the field Arquivotrailler_totalvalor
I am using the Entity Framework and my model has the following code:
public partial class ARQUIVO_GERADO_TRAILLER
{
public int ID_Arquivo { get; set; }
public string ArquivoTrailler_Conteudo { get; set; }
public int ArquivoTrailler_TotalLinhas { get; set; }
public decimal ArquivoTrailler_TotalValor { get; set; }
}
The call in the class that is entering the values is with the code below:
objArquivoGeradoTrailler.ID_Arquivo = 90;
objArquivoGeradoTrailler.ArquivoTrailler_Conteudo = "texto";
objArquivoGeradoTrailler.ArquivoTrailler_TotalLinhas = 477;
objArquivoGeradoTrailler.ArquivoTrailler_TotalValor = 137421,20;
db.ARQUIVO_GERADO_TRAILLER.Add(objArquivoGeradoTrailler);
db.SaveChanges();
I can insert this value directly into the bank table, through an Insert script. But feeding the attribute Arquivotrailler_totalvalue which is of the decimal type I get the error described above.
Change to
137421.20
Note the dot instead of the comma.– Maniero
@bigown already tested, and the mistake persists.
– Gleison França
It may be some configuration of your data model via Fluent API that may be determining the Range of your field. If possible share your entire context class, or at least the
OnModelCreating
– Pablo Tondolo de Vargas
I was able to identify the error, I was updating the field in the database but not the edmx file. Just increasing hasprecision property and it worked.
– Gleison França