Skip to content

Error when including list of Point #3169

@ghost

Description

Dear Team,

I am currently experiencing an exception with a List of Point while utilizing Entity Framework (EF) and PostgreSQL with PostGIS. The issue arose during the transition from .NET 7 to .NET 8, as the functionality was operating correctly in the former. Upon moving to .NET 8, I am unable to retrieve data due to the exception detailed in the related issue: #2975.

To facilitate the reproduction of the problem, I have prepared a minimal repository: https://github.com/workpioupiou/ErrorNpgsql. By executing the command "dotnet ef migrations add Initial --project ErrorNpgsql", the following error is generated:

"Unable to create a 'DbContext' of type ''. The exception 'When building an array mapping over 'Point', the JsonValueReaderWriter for element mapping 'NpgsqlGeometryTypeMapping`1' is incorrect ('NpgsqlJsonGeometryWktReaderWriter' instead of 'NetTopologySuite.Geometries.Point').' was thrown while attempting to create an instance."

As a temporary workaround, I have moved the List of Point into a new class, PositionPoint, which contains an ID and a property point. However, this solution required the deletion of the migrations files and the database.

I would greatly appreciate any insights or potential solutions to resolve this issue without having to delete the migrations files and the database.

public class Zone
{
    public Guid Id { get; set; }
    public List<Point> Positions { get; set; }
}

Become :

public class Zone
{
    public Guid Id { get; set; }
    public List<PositionPoint> Positions { get; set; }
}

public class PositionPoint
{
    public Guid Id { get; set; }
    public Point Position { get; set; }
}

Thank you for your time and assistance.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions