【问题标题】:No suitable constructor found for entity type 'CoordinateSystem'没有为实体类型“CoordinateSystem”找到合适的构造函数
【发布时间】:2022-04-19 15:15:19
【问题描述】:

我正在尝试生成一个包含空间列的迁移文件(几何) 我收到了这个错误

没有为实体类型“CoordinateSystem”找到合适的构造函数。以下构造函数的参数无法绑定到实体类型的属性:无法在“CoordinateSystem(int epsgId, string name, Topology topology)”中绑定“epsgId”、“topology”。

是因为 SQL 不支持空间数据吗?

我要添加到数据库的模型:

public class Polygon
{
    public int Id { set; get; }
    public int AreaId { set; get; }
    [ForeignKey("AreaId")]
    public virtual Area Area { get; set; }
    public Geometry Border { get; set; }
    [Column(TypeName = "nvarchar(7)")]
    public string Color { get; set; }
    public DateTime SelectDate { get; set; }
}

【问题讨论】:

  • “是因为 SQL 不支持空间数据吗?” SQL Server 从 SQL Server 2008 开始就支持空间数据(如果我没记错的话)。
  • 听起来您的数据库中没有Geometry 列,但您确实有CoordinateSystem

标签: c# .net sql-server geospatial entity-framework-migrations


【解决方案1】:

您的 Polygon.cs 文件需要使用 Geometry来自NetTopologySuite.Geometries

【讨论】:

    猜你喜欢
    • 2019-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 2021-08-15
    相关资源
    最近更新 更多