Error scaffolding ApiController (or Controller) with SqlServer Geography DataType (Geometry in NetTopologySuite)

I'm working on an Asp.net API with Entity Framework Core 5.

I have created the database in SQL Server and I have two tables that have a geography column for LatLong of point.

I have built the application in Visual Studio 2019 after installing all the required packages:

  • Microsoft.EntityFrameworkCore.SqlServer
  • Microsoft.EntityFrameworkCore.Design
  • Microsoft.EntityFrameworkCore.Tools
  • Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite

and generated the DbContext without errors getting in the expected Geometry column in my model classes.

The problem is that when I try to add an ApiController (or a Controller), I get the following error:

Visual Studio Error

Can anyone help?

@Fei Han: At the moment code is just a skeleton, here's the DbContext:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using Microsoft.EntityFrameworkCore;
    using NetTopologySuite.Geometries;

    #nullable disable

    namespace Helevents.Models
    {
        [Table("Fornitori")]
        public partial class Fornitori
        {
            [Key]
            [Column("idFornitore")]
            [StringLength(128)]
            public string IdFornitore { get; set; }
            [Required]
            [StringLength(80)]
            public string Fornitore { get; set; }
            [Required]
            [StringLength(50)]
            public string Nome { get; set; }
            [Required]
            [StringLength(50)]
            public string Cognome { get; set; }
            [Required]
            [StringLength(100)]
            public string Indirizzo { get; set; }
            [Column("idComune")]
            [StringLength(20)]
            public string IdComune { get; set; }
            [Required]
            public Geometry LatLong { get; set; }
            [Required]
            [Column("Tel_1")]
            [StringLength(20)]
            public string Tel1 { get; set; }
            [Column("Tel_2")]
            [StringLength(20)]
            public string Tel2 { get; set; }
            [Required]
            [StringLength(256)]
            public string Email { get; set; }
            [Required]
            [StringLength(100)]
            public string RagioneSociale { get; set; }
            [Required]
            [Column("CF_IVA")]
            [StringLength(16)]
            public string CfIva { get; set; }
            [Column(TypeName = "image")]
            public byte[] Logo { get; set; }

            [ForeignKey(nameof(IdComune))]
            [InverseProperty(nameof(Comuni.Fornitoris))]
            public virtual Comuni IdComuneNavigation { get; set; }
            [InverseProperty("IdNavigation")]
            public virtual User User { get; set; }
        }
    }

and here is one of the table classes:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using Microsoft.EntityFrameworkCore;
    using NetTopologySuite.Geometries;

    #nullable disable

    namespace Helevents.Models
    {
        [Table("Fornitori")]
        public partial class Fornitori
        {
            [Key]
            [Column("idFornitore")]
            [StringLength(128)]
            public string IdFornitore { get; set; }
            [Required]
            [StringLength(80)]
            public string Fornitore { get; set; }
            [Required]
            [StringLength(50)]
            public string Nome { get; set; }
            [Required]
            [StringLength(50)]
            public string Cognome { get; set; }
            [Required]
            [StringLength(100)]
            public string Indirizzo { get; set; }
            [Column("idComune")]
            [StringLength(20)]
            public string IdComune { get; set; }
            [Required]
            public Geometry LatLong { get; set; }
            [Required]
            [Column("Tel_1")]
            [StringLength(20)]
            public string Tel1 { get; set; }
            [Column("Tel_2")]
            [StringLength(20)]
            public string Tel2 { get; set; }
            [Required]
            [StringLength(256)]
            public string Email { get; set; }
            [Required]
            [StringLength(100)]
            public string RagioneSociale { get; set; }
            [Required]
            [Column("CF_IVA")]
            [StringLength(16)]
            public string CfIva { get; set; }
            [Column(TypeName = "image")]
            public byte[] Logo { get; set; }

            [ForeignKey(nameof(IdComune))]
            [InverseProperty(nameof(Comuni.Fornitoris))]
            public virtual Comuni IdComuneNavigation { get; set; }
            [InverseProperty("IdNavigation")]
            public virtual User User { get; set; }
        }
    }

I could replace the geography dataType in the database, but I will lose a lot of functionality.