How to Increase Decimal Precision in Entity Framework
So you are saving your decimal values to the database, but you are noticing that they are being rounded. Not what you want, because you want to be as close as you can be. If you are using entity framework you just need to add this little snippet to your OnModelCreating method in your DataContext.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Address>()
.Property(m => m.Latitude)
.HasPrecision(19, 5);
modelBuilder.Entity<Address>()
.Property(m => m.Longitude)
.HasPrecision(19, 5);
}
The example above makes sure that my latitude and longitude at least have a precision of 5. Make sure you database reflects this precision.
-
KinslayerUY
