I found that the best type to store lat and long in SQL Server is decimal (9,6) (ref. What datatype to use when storing latitude and longitude data in SQL databases?) and so I d
Apparently this guy had the exact same problem and solved it thus:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Activity>().Property(a => a.Latitude).HasPrecision(18, 9);
modelBuilder.Entity<Activity>().Property(a => a.Longitude).HasPrecision(18, 9);
}
Although you may want to look at using the spatial data types (particularly geography) in SQL Server 2008 and later.
You can use DbGeography type for storing Latitude and Longitude.
using System.Data.Entity.Spatial;
public class Test
{
public DbGeography Location { get; set; }
}
Two things:
I just purchased a Zip code database and it stores all latitude and longitude values as decimal(12,6) data type. I don't think this is going to radically change your results though.
I would check the exact SQL being sent to your SQL Server. You can then check to see where the rounding is occurring. You can check the SQL being sent by grabbing the output from EF or using SQL Profiler. My guess is that it's occuring in your C# code.
Also, it might be useful to see your table schema and your domain entity.
Use the data type of these fields as Float:
Latitude float,
Longitude float