in vnext, using Entity Framework 7 (https://github.com/aspnet/EntityFramework) how to use Spatial Data types (e.g. DbGeography
) in model (code-first method) to save points, shapes etc. when creating model for a table.
在vnext中,使用实体框架7 (https://github.com/aspnet/EntityFramework)如何在模型(代码优先方法)中使用空间数据类型(例如DbGeography)来保存点、形状等,以便为表创建模型。
e.g.
如。
public DbGeography gps_points {get; set;}
I'm unable to use DbGeography
.
我不能使用DbGeography。
Update:
更新:
Confirmed, this feature is not yet available in EF7, but may be available in future versions.
确认,这个特性在EF7中还没有可用,但可能在未来的版本中可用。
to track any changes see:
若要跟踪任何更改,请参见:
https://github.com/aspnet/EntityFramework/issues/242
https://github.com/aspnet/EntityFramework/issues/242
https://github.com/aspnet/EntityFramework/issues/1100
https://github.com/aspnet/EntityFramework/issues/1100
3 个解决方案
#1
2
Referring to your own issue at the github repository of Entity Framework, there seems no implementation, yet. As the milestone was set to "Backlog" it seems that this issue won't be resolved in the near future.
在实体框架的github存储库中引用您自己的问题,似乎还没有实现。由于里程碑设置为“Backlog”,这个问题似乎在不久的将来不会得到解决。
If you do not need to process your data geographically on database-side (e.g., search in a bounding box or intersections), you can save your data as Well-known text. This can be easily converted to a database geometry type, if EF7 supports spatial data in the future.
如果您不需要在数据库方面处理您的数据(例如,在边界框或交叉部分中搜索),您可以将您的数据保存为众所周知的文本。如果EF7将来支持空间数据,那么可以很容易地将其转换为数据库几何类型。
Be aware of the string length limits of your database, since WKT can get quiet long for complex shapes.
注意数据库的字符串长度限制,因为对于复杂的形状,WKT可以得到安静的长。
#2
0
You need to add a reference to System.Data.Entity.Spatial
. I don't think it is now included by default under the EF reference, hence the reason you cannot use DbGeography.
您需要向System.Data.Entity.Spatial添加一个引用。我不认为它现在默认包含在EF引用中,因此不能使用DbGeography。
Remember, everything is plug and play!
记住,一切都是“即插即用”的!
#3
0
Support for spatial types was introduced in EF5. However, in EF5 spatial types are only supported when the application targets and runs on .NET 4.5.
在EF5中引入了对空间类型的支持。然而,在EF5中,只有当应用程序目标在。net 4.5上运行时才支持空间类型。
Starting with EF6 spatial types are supported for applications targeting both .NET 4 and .NET 4.5.
从EF6开始,面向。net 4和。net 4.5的应用程序都支持空间类型。
the Microsoft SQL Server provider depends on some additional low-level libraries that may need to be installed.
Microsoft SQL Server提供程序依赖于一些可能需要安装的其他低级库。
Prerequisites for spatial types with Microsoft SQL Server
具有Microsoft SQL Server的空间类型的先决条件。
SQL Server spatial support depends on the low-level, SQL Server-specific types SqlGeography
and SqlGeometry
. These types live in Microsoft.SqlServer.Types.dll
assembly, and this assembly is not shipped as part of EF or as part of the .NET Framework.
SQL Server空间支持依赖于底层的、特定于SQL Server的类型SqlGeography和SqlGeometry。这些类型位于Microsoft.SqlServer.Types中。dll程序集,而这个程序集不是作为EF的一部分发布的,也不是作为。net框架的一部分发布的。
When Visual Studio is installed it will often also install a version of SQL Server, and this will include installation of the Microsoft.SqlServer.Types.dll
.
在安装Visual Studio时,它通常还会安装SQL Server的一个版本,这将包括安装Microsoft.SqlServer.Types.dll。
If SQL Server is not installed on the machine where you want to use spatial types, or if spatial types were excluded from the SQL Server installation, then you will need to install them manually. The types are included in the SQL Server Feature Packs, and different assemblies exist for SQL Server 2008 and SQL Server 2012.
如果您希望使用空间类型的机器上没有安装SQL Server,或者如果SQL Server安装中不包含空间类型,那么您需要手动安装它们。这些类型包含在SQL Server特性包中,SQL Server 2008和SQL Server 2012存在不同的程序集。
#1
2
Referring to your own issue at the github repository of Entity Framework, there seems no implementation, yet. As the milestone was set to "Backlog" it seems that this issue won't be resolved in the near future.
在实体框架的github存储库中引用您自己的问题,似乎还没有实现。由于里程碑设置为“Backlog”,这个问题似乎在不久的将来不会得到解决。
If you do not need to process your data geographically on database-side (e.g., search in a bounding box or intersections), you can save your data as Well-known text. This can be easily converted to a database geometry type, if EF7 supports spatial data in the future.
如果您不需要在数据库方面处理您的数据(例如,在边界框或交叉部分中搜索),您可以将您的数据保存为众所周知的文本。如果EF7将来支持空间数据,那么可以很容易地将其转换为数据库几何类型。
Be aware of the string length limits of your database, since WKT can get quiet long for complex shapes.
注意数据库的字符串长度限制,因为对于复杂的形状,WKT可以得到安静的长。
#2
0
You need to add a reference to System.Data.Entity.Spatial
. I don't think it is now included by default under the EF reference, hence the reason you cannot use DbGeography.
您需要向System.Data.Entity.Spatial添加一个引用。我不认为它现在默认包含在EF引用中,因此不能使用DbGeography。
Remember, everything is plug and play!
记住,一切都是“即插即用”的!
#3
0
Support for spatial types was introduced in EF5. However, in EF5 spatial types are only supported when the application targets and runs on .NET 4.5.
在EF5中引入了对空间类型的支持。然而,在EF5中,只有当应用程序目标在。net 4.5上运行时才支持空间类型。
Starting with EF6 spatial types are supported for applications targeting both .NET 4 and .NET 4.5.
从EF6开始,面向。net 4和。net 4.5的应用程序都支持空间类型。
the Microsoft SQL Server provider depends on some additional low-level libraries that may need to be installed.
Microsoft SQL Server提供程序依赖于一些可能需要安装的其他低级库。
Prerequisites for spatial types with Microsoft SQL Server
具有Microsoft SQL Server的空间类型的先决条件。
SQL Server spatial support depends on the low-level, SQL Server-specific types SqlGeography
and SqlGeometry
. These types live in Microsoft.SqlServer.Types.dll
assembly, and this assembly is not shipped as part of EF or as part of the .NET Framework.
SQL Server空间支持依赖于底层的、特定于SQL Server的类型SqlGeography和SqlGeometry。这些类型位于Microsoft.SqlServer.Types中。dll程序集,而这个程序集不是作为EF的一部分发布的,也不是作为。net框架的一部分发布的。
When Visual Studio is installed it will often also install a version of SQL Server, and this will include installation of the Microsoft.SqlServer.Types.dll
.
在安装Visual Studio时,它通常还会安装SQL Server的一个版本,这将包括安装Microsoft.SqlServer.Types.dll。
If SQL Server is not installed on the machine where you want to use spatial types, or if spatial types were excluded from the SQL Server installation, then you will need to install them manually. The types are included in the SQL Server Feature Packs, and different assemblies exist for SQL Server 2008 and SQL Server 2012.
如果您希望使用空间类型的机器上没有安装SQL Server,或者如果SQL Server安装中不包含空间类型,那么您需要手动安装它们。这些类型包含在SQL Server特性包中,SQL Server 2008和SQL Server 2012存在不同的程序集。