MS SQl Server引进两种特殊的数据类型geography and geometry
public partial class Course { public Course() { this.Students = new HashSet<Student>(); } public int CourseId { get; set; } public string CourseName { get; set; } public Nullable<int> TeacherId { get; set; } public System.Data.Spatial.DbGeography Location { get; set; } public virtual Teacher Teacher { get; set; } public virtual ICollection<Student> Students { get; set; } }
using (var ctx = new SchoolDBEntities()) { ctx.Courses.Add(new Course() { CourseName = "New Course", Location = DbGeography.FromText("POINT(-122.360 47.656)") }); ctx.SaveChanges(); }