Entity framework 将DbGeography与EF6+;SqlServerCe.4.0(.sdf数据库)。理论上可能,但不起作用

Entity framework 将DbGeography与EF6+;SqlServerCe.4.0(.sdf数据库)。理论上可能,但不起作用,entity-framework,ef-code-first,sql-server-ce,spatial,Entity Framework,Ef Code First,Sql Server Ce,Spatial,据此: ,可以使用“DbGeography”,因为它将映射到数据库端的“image”。(与使用枚举时一样,它们被映射到整数) 但是, 如果我有这个: public class Something { public long SomethingId { get; set; } public string Name { get; set; } public DbGeography Location { get; set; } } 当第一次创建数据库时(使用带有“代码优先”方

据此:
,可以使用“DbGeography”,因为它将映射到数据库端的“image”。(与使用枚举时一样,它们被映射到整数)

但是,

如果我有这个:

public class Something
{
    public long SomethingId { get; set; }
    public string Name { get; set; }
    public DbGeography Location { get; set; }
}
当第一次创建数据库时(使用带有“代码优先”方法的EF6),我会遇到以下异常:

There is no store type corresponding to the EDM type 'Edm.Geography(Nullable=True)' of primitive type 'Geography'.
我的连接字符串如下所示:

<add name="MyDbContext" connectionString="Data Source=|DataDirectory|MyDatabase.sdf" providerName="System.Data.SqlServerCe.4.0" />

我做错了什么?
我检查了,我的EF的dll是版本6

您不能这样做,MSDN文章提到复制组件将此列类型中的数据移动到SQL Compact中的“image”列

您必须使用:

[MaxLength]
public byte[] Location { get; set; } 

要存储数据并使用空间库在应用程序中来回转换

我可以在纯Linq中进行实体转换吗?例如myDbContext.Persons.Where(p=>(DbGeography)p.Location?或者我需要.ToList()在两者之间?需要ToList,是的,我无法将所有行都存储起来!你有什么建议吗?也许是一个纯SQL查询?(而不是LINQ)。使用SQL Compact是不可能的,因为它没有任何空间支持。您可以批量获取(使用跳过/获取)