我正在使用
实体框架核心2.2
具有
网络拓扑套件1.15.1
和
SQL Server 2016
. 具有类型的列
IPoint
非常有用,我想在上面创建一个索引。
我有这张桌子
public class Location
{
public int Id { get; set; }
public IPoint Coordinates { get; set; }
public static void Register(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Location>(entity => entity.HasIndex(x => new {x.Coordinates}));
}
}
而ef core在生成迁移时处理得很好,因此生成以下代码:
migrationBuilder.CreateIndex(
name: "IX_Locations_Coordinates",
schema: "data",
table: "Locations",
column: "Coordinates");
但是,一旦我尝试将迁移应用到数据库,
SqlException
与以下消息一起引发
SqlException:表“data.locations”中的列“coordinates”的类型不能用作索引或统计信息中的键列。
SQL Server
做
支持类型的列上的索引
geography
.
我相信原因可能是英孚核心试图创造一个
regular index
而不是
spatial one
.
是我做错了什么,还是只是不受支持?有没有办法告诉英孚核心应该创建空间索引?