microsoft/migrating-system-spatial
> Migrates the obsolete System.Spatial (OData v1–v3 spatial types) to Microsoft.Spatial for OData v4. Use ONLY when System.Spatial has been flagged as obsolete or deprecated and must be replaced — not for version-bump scenarios where System.Spatial is still supported.
npx skills add https://github.com/microsoft/upgrade-agent-plugins --skill migrating-system-spatial
Migrate from System.Spatial (OData v3) to Microsoft.Spatial (OData v4). This is primarily a namespace change — the spatial type APIs (GeographyPoint, GeometryPoint, GeographyLineString, etc.) remain largely compatible. The main work is updating using directives and adjusting any SpatialFormatter or extension method references.
<PackageReference Include="System.Spatial" Version="{old-version}" />
<PackageReference Include="Microsoft.Spatial" Version="{version}" />
Migration Progress:
- [ ] Step 1: Detect System.Spatial usage
- [ ] Step 2: Update project file references
- [ ] Step 3: Update namespace references
- [ ] Step 4: Adjust API differences
- [ ] Step 5: Build and verify
Scan the project for:
using System.Spatial; statementsGeographyPoint, GeometryPoint, GeographyLineString, GeometryLineString, GeographyPolygon, GeometryPolygonSpatialFormatter and GeoJsonObjectFormatter usageGeographyOperationsExtensions method calls (e.g., Distance)Remove System.Spatial and add Microsoft.Spatial (see "Package Reference Changes" above). If the project uses OData client or server libraries, ensure they are also updated to OData v4 versions that depend on Microsoft.Spatial.
Replace all namespace references:
// Old
using System.Spatial;
// New
using Microsoft.Spatial;
This covers all spatial types — the type names themselves are unchanged.
| System.Spatial (Old) | Microsoft.Spatial (New) | Notes |
|---------------------|------------------------|-------|
| System.Spatial.GeographyPoint | Microsoft.Spatial.GeographyPoint | Same API, different namespace |
| System.Spatial.GeometryPoint | Microsoft.Spatial.GeometryPoint | Same API, different namespace |
| System.Spatial.SpatialFormatter | Microsoft.Spatial.SpatialFormatter | Same API, different namespace |
| System.Spatial.GeoJsonObjectFormatter | Microsoft.Spatial.GeoJsonObjectFormatter | Improved GeoJSON support in v4 |
| System.Spatial.GeographyOperationsExtensions | Microsoft.Spatial.GeographyOperationsExtensions | Extension methods for Distance, Length, etc. |
| SpatialValidator.Create() | SpatialValidator.Create() | Same API, different namespace |
Factory methods like GeographyPoint.Create(latitude, longitude) retain the same signature. No code changes beyond the namespace are needed for these calls.
dotnet build
geo.distance, geo.intersects) still workIf both System.Spatial and Microsoft.Spatial are referenced (e.g., via transitive dependencies), the compiler will report ambiguous type errors. Remove the System.Spatial package and ensure no transitive dependency pulls it in. Use dotnet list package --include-transitive to check.
Microsoft.Spatial is part of the OData v4 ecosystem. If other OData packages in the project still target v3 (e.g., Microsoft.Data.OData), they may bring in System.Spatial transitively. Upgrade all OData packages to v4 together.
If Distance() or other extension methods are unresolved after the namespace change, verify that using Microsoft.Spatial; is present — the extension methods are in the GeographyOperationsExtensions class in the same namespace.
Take microsoft/migrating-system-spatial from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.