question

JM-6363 avatar image
0 Votes"
JM-6363 asked BenRoth-7071 edited

Future of Microsoft.SqlServer.Types in .NET Core or .NET 6

Greetings,

Attempting to move beyond Microsoft.SqlServer.Types full framework to a more scalable solution using .NET Core has proven to be difficult. Net Topology Suite does not use geography outright but supports geography by projecting into a defined coordinate system using transforms and then doing work on it with geometry operations.

dotMorten has created a Microsoft.SqlServer.Types lib on GitHub, but that is limited in that you have to define the more complicated spatial operations yourself, hoping that they align with the old defined operations in Microsoft.SqlServer.Types/SqlServerSpatial assemblies.

Has there been any effort or discussion to redo the old Microsoft.SqlServer.Types binaries for use in .NET Core or even .NET 6?

sql-server-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered

Your question is about .Net Core. The .Net Core forums are here https://docs.microsoft.com/en-us/answers/products/dotnet?WT.mc_id=dotnet-35129-website

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

cooldadtx avatar image
0 Votes"
cooldadtx answered BenRoth-7071 commented

Discussions around spatial types in .NET 5+ are handled on the new Microsoft.Data.SqlClient repo. They are building out the next generation tools for SQL in .NET 5+. There is already a discussion about spatial types here that you can join in on to see where they are going with it.

Microsoft.SqlServer.Types is actually part of SQL Server and not .NET. I would not consider it a future-focused assembly to work with. You should probably consider switching to Microsoft.Data.SqlClient if at all possible.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Switching to Microsoft.Data.SqlClient for connection and data transfer isn't relevant to this question because there are no types in that or related assemblies which are equivalent to, or convertible from, SqlGeography. System.Data.Spatial and the DbGeography type has not been carried forward past .NET4.8

0 Votes 0 ·
BenRoth-7071 avatar image
0 Votes"
BenRoth-7071 answered BenRoth-7071 edited

There is currently an open issue about this here: https://github.com/dotnet/SqlClient/issues/30 The old assemblies can still be used in .NET Core, but only on windows machines, and with other limitations. (details are available in comments on the issue).

However since there's been no substantive movement in the 3 years since this issue was opened, if you're unable to use the existing native assemblies then your best bet is probably to output the data to a 3rd party nuget that has the functionality you need. https://github.com/DotSpatial/DotSpatial and https://github.com/GeoJSON-Net/GeoJSON.Net are both referenced in the SqlClient Issue, with GeoJSON.NET apparently being able to import and export while converting with geography.STAsBinary() on the sql server side.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.