I have a database field defined as decimal(9,9). The edmx model in C# maps this field to a decimal variable with a precision and scale of 9.
I put the number 5 in the variable. Everywhere I can check shows the value as 5 (in local variables, the entity class instance, data context, etc.).
At the time of DataContex.SaveChanges()
the value is converted to "5.000000000". As best I can tell the entity framework is adding 9 decimal places to the value before trying to save to the database. This causes an error because the value now has too many digits.
Does anyone know what causes this behavior and how I can change it?
Addition Information - I started by creating my database in Microsoft SQL 2008 R2. I then generated the Entity Framework model from the database.
If you really have defined your data type as decimal(9,9)
in your database, you've got a problem.
According to Microsoft, the first number is the total number of digits, the second the number of digits to the right of the decimal point.
So you can really only store numbers below 1 in such a field, in the format .123456789
.
If you need to store 5, you will need a different format.