Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 类型为“的EntityKey属性;地理&x201D;不支持。实体框架5,VS 2012和x2013;数据库优先_Visual Studio_Entity Framework_Spatial - Fatal编程技术网

Visual studio 类型为“的EntityKey属性;地理&x201D;不支持。实体框架5,VS 2012和x2013;数据库优先

Visual studio 类型为“的EntityKey属性;地理&x201D;不支持。实体框架5,VS 2012和x2013;数据库优先,visual-studio,entity-framework,spatial,Visual Studio,Entity Framework,Spatial,创建了一个SQL Server 2008数据库和表,其属性名为“坐标”,类型为“地理”。在VS 2012中创建了一个项目,添加了对Microsoft.SqlServer.Types和EF V5的引用。然后,使用ADO.NET实体数据模型向导生成edmx。在VS 2012中编译时,出现以下错误: Error 4 Error 129: The property 'Coordinates' in EntityType 'DBModel.GeoDestination' is not valid.

创建了一个SQL Server 2008数据库和表,其属性名为“坐标”,类型为“地理”。在VS 2012中创建了一个项目,添加了对Microsoft.SqlServer.Types和EF V5的引用。然后,使用ADO.NET实体数据模型向导生成edmx。在VS 2012中编译时,出现以下错误:

Error   4   Error 129: The property 'Coordinates' in EntityType 'DBModel.GeoDestination' is not valid. EntityKey properties that are of type 'Geography' are currently not supported.
web上的许多示例都是“代码优先”示例,它们在c#code中使用类型“DbGeography”作为类型,并从代码生成数据库,生成一个具有类型“geography”属性的表

我如何首先处理这个数据库并修复类型?在使用“表映射”视图时,“DBGeography”似乎不在类型的下拉列表中


使用EF5、NET4.5和2012 SP1,SQL Server类型

我发现了这一点。看起来像是向导中的错误。如果SQL中的表没有主键,向导将在生成的EF模型中自动生成一个键。它看起来是随机的,有时生成一个键,有时生成多个属性键。地理数据类型不能是键。它不是表中的键,但向导将其设置为键


希望此响应能帮助其他人。

例外情况是,
坐标
不得标记为实体的键。数据库表的主键是什么?