title: Using Postgis' Geometry type with Entity Framework
body: <p>I've been trying to build my first ever API project using ASP.NET Core.</p>
  <p>Everything is going smoothly, except for one thing. Whenever I try to add a new scaffolded controller (after adding my models, of course), I get the following error:</p>
  <blockquote>
  <p>The property 'Favor.Coordinates' is of type 'Geometry' which is not supported by current database provider. Either change the property CLR type or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.</p>
  </blockquote>
  <p>This is self-explanatory; I've got a model class with a <code>Geometry</code> type (from Postgis), which seems to be causing issues for Entity Framework.</p>
  <p><strong>What have I done?</strong></p>
  <ul>
  <li>I have created my DB and added the Postgis extension to be able to use the Geometry data type</li>
  <li>I have added the <code>Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite</code> package to support the <code>Geometry</code> in my project, as detailed in the following tutorial: <a href="https://docs.microsoft.com/en-us/ef/core/modeling/spatial" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/ef/core/modeling/spatial</a></li>
  <li>I have added all required Npgsql extensions to use PostgreSQL with ASP.NET, and generated all model classes from the database</li>
  </ul>
  <p>It's important to mention that I also added the <code>NetTopologySuite</code> package before generating my models, just as the tutorial mentions. Nevertheless, whenever I tried to add a scaffolded API controller using Entity Framework, I get the aforementioned error, despite the fact that NTS does <em>support</em> <code>Geometry</code>.</p>
  <p>For further reference, here's the <code>Favor</code> class that the error mentions:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using NetTopologySuite.Geometries;
  
  namespace FavorAPI.Models
  {
      public partial class Favor
      {
          public Favor()
          {
              Payment = new HashSet&lt;Payment&gt;();
              Request = new HashSet&lt;Request&gt;();
          }
  
          public int Idfavor { get; set; }
          public string Description { get; set; }
          public string Title { get; set; }
          public DateTime? Creationtime { get; set; }
          public DateTime? Happeningtime { get; set; }
          public double? Price { get; set; }
          public short? Estimatedtime { get; set; }
          public short? Maxpeople { get; set; }
          public short? Currentpeople { get; set; }
          public Geometry Coordinates { get; set; } //&lt;-- Problematic!
          public int? Idstatus { get; set; }
          public int? Idposter { get; set; }
          public int? Idcategory { get; set; }
  
          public virtual Category IdcategoryNavigation { get; set; }
          public virtual Individual IdposterNavigation { get; set; }
          public virtual Favorstatus IdstatusNavigation { get; set; }
          public virtual ICollection&lt;Payment&gt; Payment { get; set; }
          public virtual ICollection&lt;Request&gt; Request { get; set; }
      }
  }
  </code></pre>
  <p>I have also added <code>x =&gt; x.UseNetTopologySuite()</code> to my DB context. Does anyone have an idea of what could I be doing wrong? I can always add the <code>[NotMapped]</code> attribute mentioned by the error, but I <em>do</em> want this attribute to be mapped.</p>
  <p>Thanks in advance!</p>
  <p><strong>Edit:</strong> Creating the controllers manually (rather than through scaffolding) works and throws no errors, but eventually the same error message appears if I try to access the route to any of the controller's endpoints.</p>