DbGeography 属于一种无效的类型,不能用作索引或统计信息中的键列
DbGeography is of a type that is invalid for use as a key column in an index or statistics
我首先使用 Entity Framework 6.1 代码,我试图在 DbGeography
类型的列上创建索引,因为我的应用程序主要以位置为中心,所以 不索引 不是一个选项。
这是我class上的相关部分:
public class Post
{
...
[Required, Index(Order = 1)]
public DateTime CreateDate { get; set; }
[Required, Index(Order = 2)]
public DbGeography Location { get; set; }
...
}
然而,当我 运行 我的应用程序(我正在使用 SQL Azure)时,我得到:
Column 'Location' in table 'dbo.Posts' is of a type that is invalid for use as a key column in an index or statistics.
如何在不关闭空间索引的情况下解决这个问题?
不幸的是,空间类型不能用作 Entity Framework 中的实体键,因为它们的工作方式类似于过滤索引。此 post 包含有关使用 Spatial Types in the Entity Framework 的更多信息。
我首先使用 Entity Framework 6.1 代码,我试图在 DbGeography
类型的列上创建索引,因为我的应用程序主要以位置为中心,所以 不索引 不是一个选项。
这是我class上的相关部分:
public class Post
{
...
[Required, Index(Order = 1)]
public DateTime CreateDate { get; set; }
[Required, Index(Order = 2)]
public DbGeography Location { get; set; }
...
}
然而,当我 运行 我的应用程序(我正在使用 SQL Azure)时,我得到:
Column 'Location' in table 'dbo.Posts' is of a type that is invalid for use as a key column in an index or statistics.
如何在不关闭空间索引的情况下解决这个问题?
不幸的是,空间类型不能用作 Entity Framework 中的实体键,因为它们的工作方式类似于过滤索引。此 post 包含有关使用 Spatial Types in the Entity Framework 的更多信息。