在代码优先实现中使用Entity Framework 6的非常简单的MVC 5站点上发生此错误。其中一些模型使用System.Data.Entity.Spatial.DbGeography,如下面的模型。
using System;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.Spatial;
namespace ProjectName.Models
{
public class PostalCode
{
[Key]
[MaxLength(10)]
public string PostalCodeValue { get; set; }
public int Country { get; set; }
[MaxLength(2)]
public string StateAbbr { get; set; }
public DbGeography Geo { get; set; }
}
}
在生产移动到外部测试环境期间,我们收到以下错误:
There is no store type corresponding to the conceptual side type 'Geography' of primitive type 'Geography'.
答案 0 :(得分:2)
这个错误有点误导。在我们的示例中,连接字符串指向数据库中早于SQL2012的站点的早期版本。
发生这种情况的原因是因为目标数据库无法处理此数据类型。如果收到此验证,则验证连接字符串是否以正确的数据库为目标,并且它是否能够指定错误指定的数据类型。