.net core 实体类型'没有合适的构造函数;行字符串';

.net core 实体类型'没有合适的构造函数;行字符串';,.net-core,entity-framework-core,asp.net-core-webapi,postgis,.net Core,Entity Framework Core,Asp.net Core Webapi,Postgis,尝试将集成测试从内存数据库迁移到PostGIS数据库时,我在调用EnsurereDeleted或Ensurerecreated方法时总是捕捉到该异常: System.InvalidOperationException No suitable constructor found for entity type 'LineString'. The following constructors had parameters that could not be bound to properties o

尝试将集成测试从内存数据库迁移到PostGIS数据库时,我在调用
EnsurereDeleted
Ensurerecreated
方法时总是捕捉到该异常:

System.InvalidOperationException
No suitable constructor found for entity type 'LineString'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'points' in 'LineString(Coordinate[] points)'; cannot bind 'points', 'factory' in 'LineString(CoordinateSequence points, GeometryFactory factory)'.
通过内存测试,一切正常

具有空间数据的唯一模型如下所示:

public class surveilledera
{
[关键]
[数据库生成(DatabaseGeneratedOption.Identity)]
公共int Id{get;set;}
公共字符串名称{get;set;}
[列(TypeName=“几何体(多边形)”)]
公共多边形{get;set;}
公共字符串AvigilonAlertId{get;set;}
公共城市内部ID{get;set;}
公共虚拟自治市{get;set;}
}
我的背景是

公共类AppDbContext:DbContext
{
公共AppDbContext(DbContextOptions DbContextOptions):基本(DbContextOptions)
{
}
公共虚拟数据库集区域{get;set;}
公共虚拟数据库集{get;set;}
公共虚拟数据库集报告{get;set;}
公共虚拟数据库集设备{get;set;}
模型创建时受保护的覆盖无效(ModelBuilder ModelBuilder)
{
modelBuilder.HasPostgresExtension(“postgis”);
modelBuilder.Entity()
.HasOne(p=>p
.有许多(p=>p.surveillederas)
.HasForeignKey(p=>p.市政ID)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity()
.HasOne(p=>p.Device)
.WithMany(p=>p.Reports)
.HasForeignKey(p=>new{p.DeviceType,p.DeviceAdId})
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity()
.HasIndex(p=>p.ShortCode)
.IsUnique();
modelBuilder.Entity()
.HasKey(device=>new{device.Type,device.advisingid});
基于模型创建(modelBuilder);
}
}

我做错了什么?

那么,你是说,你的代码中没有任何
LineString
类?那么,我做了一个解决方案范围的搜索,没有任何LineString,我只有一个多边形,它们都是从几何体继承的(但我认为这不是很相关)。你添加了
o=>o.usenetpologysuite()
在Npgsql的配置中?您确实有一个LineString,如果已安装,请从Startup.cs发布Npgsql和DbContext配置。您是否在任何地方添加了
UseNetTopologySuite()
?是的。克隆repo、删除迁移文件夹并重新创建它们解决了问题。现在,对于这个项目,我是后端唯一的开发人员,我知道我可以做到这一点,但问题是对于一个团队项目。那么,你是说,你的代码中没有任何
LineString
类?所以,我做了一个解决方案范围的搜索,没有任何LineString,我只有一个多边形,并且都继承自几何体(但我认为这不是很相关)。您是否在
Npgsql
的配置中添加了
o=>o.UseNetTopologySuite()
?如果您安装了,请从Startup.cs发布Npgsql和DbContext配置。是否添加了
UseNetTopologySuite())
anywhere?是的。克隆repo、删除迁移文件夹并重新创建它们解决了问题。现在,对于这个项目,我是后端唯一的开发人员,我知道我可以做到这一点,但问题是对于团队项目。