entity framework spatial support for multi-polygon and polygon
Posted by: Yanhua Wang
Date: September 01, 2018 01:10AM

I use entity framework to access tables as follows:

CREATE TABLE `myplaces`
(

`Id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`location` geometry DEFAULT NULL,

PRIMARY KEY (`Id`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;


the type of `location` column is geometry, mapping to the
CLR type `System.Data.Entity.Spatial.DbGeometry`

If I seed datas to the database by construct DbGeometry
such as DbGeometry.FromText("POINT(40.735031 -73.768387)"),
it works well.

However, when I construct DbGeometry such as
DbGeometry.FromText("POLYGON((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))"),
an IndexOutofRangeException was through out.

the stack trace show as follows:
於 MySql.Data.Entity.Metadata.NormalizeValue(TypeUsage type, Object value)
於 MySql.Data.Entity.SqlGenerator.Visit(DbConstantExpression expression)
於 System.Data.Entity.Core.Common.CommandTrees.DbConstantExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
於 MySql.Data.Entity.InsertGenerator.GenerateSQL(DbCommandTree tree)
於 MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)

I have suyveyed how to access spatial with ef in MySQL. the samples are always
demoed with points. Does entity framework to mysql support accessing polygon or multi-polygon?

Requirements:

- OS windows:10

- Connector/Net 6.10.8.0

- Entity Framework 6.2.0 version

- .NET Framework 4.5.2 version

- Microsoft.SqlServer.Types 14.0.0.0

Options: ReplyQuote


Subject
Written By
Posted
entity framework spatial support for multi-polygon and polygon
September 01, 2018 01:10AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.