0

I'm developing app in .NET Core 3.1 with Visual Studio 2019 and everything works fine on my local machine with Windows 10 Pro. But after deploy to Azure this problem occurs:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 9 ("@p8"): The supplied value is not a valid instance of data type geography. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision

This error occurs when adding Post to database. Post has property of type NetTopologySuite.Geometries.Point and is set like that: location = new Point(longitude, latitude) { SRID = 4326 }; where longitude and latitude are double.

When I set location to null then error doesn't appear. I tried to use less precision, like 2 digits before dot and 6 digits after - this still causes error.

I use Entity Framework Core. It generated db column as Location (geography, null).

Edit: I'm converting lat and lon strings to double like that: Convert.ToDouble(longitude.Replace(".", ",")). I removed .Replace(".", ",") and now it works on Azure, but the same error appear on local env. I have spatial with id 4326 on both dbs.

Piotrek
  • 1,304
  • 8
  • 16
  • Hello, other has the same error and resolved it. please ref: https://stackoverflow.com/questions/59493887/entity-framework-core-3-1-with-nettopologysuite-geometries-point-sqlexception/59667168#59667168 and https://github.com/dotnet/efcore/issues/19416. – Leon Yue Jun 23 '20 at 02:12
  • The problem was something else. There is spatial 4326 in azure db. – Piotrek Jun 23 '20 at 08:16

1 Answers1

0

Finally i changed:

Convert.ToDouble(longitude.Replace(".", ","))

to

Convert.ToDouble(longitude, CultureInfo.InvariantCulture)

and now it works on both - local and Azure.

Solution inspired by this: string to double issue, dot is removed

Piotrek
  • 1,304
  • 8
  • 16