数据库表:
,[Location] GEOGRAPHY
使用 SRID 104001 使用 EF 更新位置
item.Location = System.Data.Entity.Spatial.DbGeography.PointFromText($"Point({loc.Lng} {loc.Lat})", 104001);
例外:
24204: 空间参考标识符 (SRID) 无效。指定的 SRID 必须与 sys.spatial_reference_systems 目录视图中显示的支持的 SRID 之一匹配。
数据库检查:
SELECT * FROM sys.spatial_reference_systems WHERE spatial_reference_id = 104001
104001 Microsoft 104001 GEOGCS["Unit Sphere", DATUM["Unit Sphere", SPHEROID["Sphere", 1.0, 0.0]], PRIMEM["Greenwich",0.0], UNIT["Degree", 0.0174532925199433]] radian 1
使用:
.Net Framework 4.6.1;
Entity Framework 6.1.3;
Microsoft SQL Server 2014 (SP2-GDR) (KB3194714) - 12.0.5203.0 (X64) Sep 23 2016 18:13:56 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) ;
Database Compatibility level 120