长时间的听众,第一次来电(终于在这里注册了一个帐户!)...
我正在使用带有.NET 4.5.1和Entity Framework 6(最终版本,不是 RC 或 beta)的Visual Studio 2013 。
尝试将 DbGeography 属性添加到我的实体时,执行时出现此错误:
One or more validation errors were detected during model generation:
Geocoder.DbGeography: : EntityType 'DbGeography' has no key defined.
Define the key for this EntityType.
DbGeographies: EntityType: EntitySet 'DbGeographies' is based on type 'DbGeography' that has no keys defined.
我已经确认我没有引用旧版本的实体框架(在此处讨论)。我一直在使用这篇文章和这篇 MSDN 文章作为示例/信息,因为这是我第一次涉足 .NET(以及 SQL Server,就此而言)中的空间类型。
这是我的实体:
public class Location
{
public int Id { get; set; }
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public virtual State State { get; private set; }
public string ZipCode { get; set; }
public string ZipCodePlus4 { get; set; }
public DbGeography Geocode { get; set; }
public Hours Hours { get; set; }
public virtual ICollection<Language> Languages { get; private set; }
public virtual OfficeType OfficeType { get; private set; }
[JsonIgnore]
public virtual ICollection<ProviderLocation> Providers { get; private set; }
}
我究竟做错了什么?