相关疑难解决方法(0)

EntityType'DbGeography'没有定义键

长时间听众,第一次来电(最后在这里开了帐户!)......

我正在使用Visual Studio 2013.NET 4.5.1实体框架6(最终版本,而不是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.
Run Code Online (Sandbox Code Playgroud)

我已经确认我没有引用旧版本的Entity Framework(这里讨论).我一直在使用这篇文章这篇MSDN文章中的示例/信息,因为这是我第一次涉及.NET中的空间类型(以及SQL Server,就此而言).

这是我的实体:

public class Location
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework sqlgeography entity-framework-5

25
推荐指数
1
解决办法
5410
查看次数