I have noticed some strange time saving values double
in the SQL Server database with the Entity Framework.
I noticed that when reporting a value ex: 12.23 after saving the information is breaking the decimals in more houses ex: 12.22501.
This does not occur often and not every time a value is written, and it also has no impact on the calculations (since I do not use round
).
My questions are:
- Why does this occur?
- Has anyone ever gone through this? How did you decide?
- Is this setting or depends on the database type?
The structure I use is the information below:
public class MyClass
{
public double MyClass { get; set; };
}
public class MyContext : DbContext
{
public DbSet<MyClass> MyClass;
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<MyClass>().Property(x => x.ValorTeste).HasPrecision(16, 5);
}
}