实体框架6和空间数据 [英] Entity framework 6 and spatial data

查看:121
本文介绍了实体框架6和空间数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有空间数据类型的数据库。我用的数据库,第一个模型和Entity Framework 6.0.2和.NET 4.5。当我试图使用生成的类我得到以下错误:指定

I have database with spatial data types. I use database first model and entity framework 6.0.2 and .NET 4.5. When I am trying to use the generated classes I get following error:

模式是无效的。未加载
的关系'Name_FK1,因为类型Model.TypeB不可用:错误。
以下信息可以解决以前的错误是有用的:
的类型属性'位置'Data.TypeB'有'System.Data.Spatial.DbGeography这不可能是一个属性类型映射到一个基本类型。

Schema specified is not valid. Errors: The relationship 'Name_FK1' was not loaded because the type 'Model.TypeB' is not available. The following information may be useful in resolving the previous error: The property 'Position' on the type 'Data.TypeB' has a property type of 'System.Data.Spatial.DbGeography' which cannot be mapped to a primitive type.

已列出,我使用空间类型的所有表同样的错误。在'Name_FK1'是外键关系。

The same error is listed for all tables where I use spatial type. The ‘Name_FK1’ is foreign key relation.

我在做什么错了?

感谢您的帮助。

推荐答案

我修好了!很为自己感到骄傲:)

I fixed it! Very proud of myself :)

希望这可以帮助别人。所以,从上面的链接( http://msdn.microsoft.com/en-US/data/dn469466)这行:

Hope this helps somebody else. So, from the link above (http://msdn.microsoft.com/en-US/data/dn469466) there is this line:

空间类(如DbGeography,DbGeometry)已经从
移动System.Data.Spatial => System.Data.Entity.Spatial

Spatial classes (e.g. DbGeography, DbGeometry) have moved from System.Data.Spatial => System.Data.Entity.Spatial

在我得到这个错误:

的关系IntakeModel.FK_Assignee_HomeLocation未加载
,因为类型'IntakeModel.Location不可用。在
下列信息可能会解决以前的错误有用:
酒店'地理'的类型'ConsoleApplication3.Location'有'System.Data.Spatial.DbGeography的
属性类型'不能被映射到一个基本类型

The relationship 'IntakeModel.FK_Assignee_HomeLocation' was not loaded because the type 'IntakeModel.Location' is not available. The following information may be useful in resolving the previous error: The property 'Geo' on the type 'ConsoleApplication3.Location' has a property type of 'System.Data.Spatial.DbGeography' which cannot be mapped to a primitive type.

我只是在我的Location.cs文件来改变这样的:

I just had to change this in my Location.cs file:

public System.Data.Spatial.DbGeography Geo { get; set; }

要这样:

public System.Data.Entity.Spatial.DbGeography Geo { get; set; }



问题解决了。感谢张贴该链接@Ricky琼斯。

Problem solved. Thanks for posting that link @Ricky Jones.

这篇关于实体框架6和空间数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆