【问题标题】:How do I save DbGeography data to SQL Server Compact using Entity Framework?如何使用实体框架将 DbGeography 数据保存到 SQL Server Compact?
【发布时间】:2014-03-18 22:36:19
【问题描述】:

我正在使用 Entity Framework 6.0.2 将类映射到数据库。其中一个类包含 DbGeography 属性:

public DbGeography Coordinate { get; set; }

当我使用 SQL Server Express 时,一切都很好,但是当我切换到 SQL Server Compact 时,我收到下一个错误:

There is no store type corresponding to the EDM type 'Edm.Geography(Nullable=True)' of primitive type 'Geography'.

我从here 发现可以存储地理数据并将其转换为“图像”类型。但下一次尝试没有给出结果:

[Column(TypeName = "image")]
public DbGeography Coordinate { get; set; }

所以问题是:将地理数据转换为图像并将其存储在 SQL Server Compact 中的正确方法是什么?

【问题讨论】:

  • 您找到的文档与合并复制有关,而不是实体框架,我认为您需要映射到 byte[],并使用 .NET 空间类型在您的应用中进行转换

标签: sql-server entity-framework sql-server-ce


【解决方案1】:

由于我只需要 Area 属性,因此我刚刚将该数据以 WKT 格式存储为“POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多