title: Entity Framework Core 3.1 with NetTopologySuite.Geometries.Point: SqlException: The supplied value is not a valid instance of data type geography
body: <p>I have a model that looks like this:</p>
  
  <pre><code>public class Facility
  {
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }
  
      public NetTopologySuite.Geometries.Point Location { get; set; }
  }
  </code></pre>
  
  <p>Test code for adding a Point:</p>
  
  <pre><code>var testFacility = new Facility();
  testFacility.Location = new NetTopologySuite.Geometries.Point(13.003725d, 55.604870d) { SRID = 3857 };
  
  //Other values tested with the same error error
  
  //testFacility.Location = new NetTopologySuite.Geometries.Point(13.003725d, 55.604870d);
  
  //testFacility.Location = new NetTopologySuite.Geometries.Point(55.604870d, 13.003725d);
  
  //var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 3857);
  //var currentLocation = geometryFactory.CreatePoint(new Coordinate(13.003725d, 55.604870d));
  //testFacility.Location = currentLocation;
  
  db.Facilities.Add(testFacility);
  //Exception on Save
  db.SaveChanges();
  </code></pre>
  
  <p>I'm using the following NuGets, version <code>3.1.0</code></p>
  
  <pre><code>Microsoft.AspNetCore.Identity.EntityFrameworkCore
  Microsoft.EntityFrameworkCore.SqlServer
  Microsoft.EntityFrameworkCore.Tools
  Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
  </code></pre>
  
  <p>The exception I get on save is the following:</p>
  
  <blockquote>
    <p>SqlException: The incoming tabular data stream (TDS) remote procedure
    call (RPC) protocol stream is incorrect. Parameter 7 ("@p6"): 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.</p>
  </blockquote>
  
  <p>According to all documentation it should be X for longitude and Y for latitude so I don't think that is a problem. I tried to reverse the coordinates just in case but I got the same error as you can see in the examples I have tried. </p>
  
  <p><a href="https://docs.microsoft.com/en-us/ef/core/modeling/spatial" rel="noreferrer">https://docs.microsoft.com/en-us/ef/core/modeling/spatial</a></p>
  
  <p>Lat = Y Long = X</p>
  
  <p><a href="https://gis.stackexchange.com/a/68856/71364">https://gis.stackexchange.com/a/68856/71364</a></p>
  
  <p>I can't find out anything obvious that seems wrong. Optionsbuilder is set up, the table is created with Data Type <code>geography</code> that worked really well with <code>DbGeography</code> for Entity Framework 6.</p>
  
  <pre><code>var optionsBuilder = new DbContextOptionsBuilder&lt;ApplicationDbContext&gt;();
  optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=TestDb;Trusted_Connection=True;MultipleActiveResultSets=true",
      x =&gt; x.UseNetTopologySuite());
  
  var db = new ApplicationDbContext(optionsBuilder.Options);
  </code></pre>
  
  <p>There is no specific cases to handle for a single <code>Point</code> either what I can see in documentation for SQL server.</p>
  
  <p><a href="https://docs.microsoft.com/en-us/ef/core/modeling/spatial#sql-server" rel="noreferrer">https://docs.microsoft.com/en-us/ef/core/modeling/spatial#sql-server</a></p>
  
  <p>The coordinates I'm saving is from Google Maps and therefore <code>EPSG 3857</code> is used.</p>
  
  <p><a href="https://gis.stackexchange.com/questions/48949/epsg-3857-or-4326-for-googlemaps-openstreetmap-and-leaflet">https://gis.stackexchange.com/questions/48949/epsg-3857-or-4326-for-googlemaps-openstreetmap-and-leaflet</a></p>
  
  <p>What am I missing?</p>