EntityFramework 学习 一 Spatial Data type support in Entity Framework 5.0

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();
}
        
原文地址:https://www.cnblogs.com/lanpingwang/p/6622763.html