Efcore.pg: Type 'Point' which is not supported by current database provider

Created on 24 Jul 2018  路  4Comments  路  Source: npgsql/efcore.pg

I got the following error when I generated the code first migration.

The property 'Scheme.Polygon' is of type 'Point' 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'.

-----------There are what I did------------

  1. Startup.cs
    ```C#
    services.AddDbContext(options =>
    options.UseNpgsql(connectionString, o => o.UseNetTopologySuite()));
2. Entity model:
```C#
using NetTopologySuite.Geometries;
public class Scheme
{
    public Point Polygon { get; set; }
}
  1. DbContext:
    ```C#
    protected override void OnModelCreating(ModelBuilder builder)
    {
    builder.HasPostgresExtension("postgis");
    base.OnModelCreating(builder);

     builder.Entity<Scheme>(options =>
     {
         options.Property(m => m.Polygon).HasColumnType("geography");
     });
    

    }
    ```

  2. I am using .net core 2.1, entity framework core & postgresql 10.
    Thanks!

Most helpful comment

Ok, I was missing the mapping part:
b.Property(m => m.Coordinates).HasColumnType("geography");

All 4 comments

I'm running into the exact same problem. Didn't find any working solution as of yet.

Possibly the same issue being investigated in #553. Could you take a look and let us know if you believe this is a separate issue?

If you believe it is distinct, could you please post a complete repro for us to clone and investigate?

Ok, I was missing the mapping part:
b.Property(m => m.Coordinates).HasColumnType("geography");

Closing as no additional info was provided within 7 days.

Please feel free to post back here with the relevant information and we can reopen if necessary.

Was this page helpful?
0 / 5 - 0 ratings