EntityType’DbGeography’没有定义键

长时间听众,第一次来电(终于在这里开了帐户!)……

我正在使用Visual Studio 2013.NET 4.5.1entity framework6 (最终版本,而不是RC或beta)。

在尝试向我的实体添加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. 

我已经确认我没有引用旧版本的Entity Framework( 这里讨论过 )。 我一直在使用这篇文章和这篇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 Languages { get; private set; } public virtual OfficeType OfficeType { get; private set; } [JsonIgnore] public virtual ICollection Providers { get; private set; } } 

我究竟做错了什么?

事实certificate,这与我在微软自己对Codeplex中类似问题的回应中所读到的相反,甚至是他们的文档 。 我错误地解释了吗? 这两个链接都表明在EF 6中,DbGeography数据类型已从System.Data.Entity.Spatial移动到System.Data.Spatial,但反之亦然。

我变了

 using System.Data.Spatial; 

 using System.Data.Entity.Spatial; 

它的工作原理。