entity framework - Inserting Spatial\Geometry in EF5 with dotConnect 6.7 for PostgreSQL -
i installed latest dotconnect postgresql. im trying insert record in postgres db. have geometry column gives me errors. here code:
using (var context = new wkp_dbentities()) { var location = dbgeometry.pointfromtext(string.format("point({0} {1})", 157873, 364282), 28992); var record = new monitoring_object() { geometry = location, last_changed_by = "ssg", }; context.monitoring_object.add(record); context.savechanges(); }
here error message:
system.data.entity.infrastructure.dbupdateexception unhandled hresult=-2146233087 message=an error occurred while updating entries. see inner exception details. source=entityframework stacktrace: @ system.data.entity.internal.internalcontext.savechanges() @ system.data.entity.internal.lazyinternalcontext.savechanges() @ system.data.entity.dbcontext.savechanges() @ consoleapplicationgeodata.program.main(string[] args) in c:\users\stefan\documents\visual studio 2012\projects\consoleapplicationgeodata\consoleapplicationgeodata\program.cs:line 38 @ system.appdomain._nexecuteassembly(runtimeassembly assembly, string[] args) @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args) @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() @ system.threading.threadhelper.threadstart_context(object state) @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean preservesyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.threadhelper.threadstart() innerexception: system.data.updateexception hresult=-2146233087 message=an error occurred while updating entries. see inner exception details. source=system.data.entity stacktrace: @ system.data.mapping.update.internal.updatetranslator.update(ientitystatemanager statemanager, ientityadapter adapter) @ system.data.entityclient.entityadapter.update(ientitystatemanager entitycache) @ system.data.objects.objectcontext.savechanges(saveoptions options) @ system.data.entity.internal.internalcontext.savechanges() innerexception: system.argumentexception hresult=-2147024809 message=cannot convert value source=devart.data.postgresql stacktrace: @ devart.data.postgresql.af.a(object a_0, type a_1, encoding a_2) @ devart.data.postgresql.af.a(string a_0, encoding a_1, pgsqltype a_2, object a_3, int32 a_4, boolean a_5) @ devart.data.postgresql.pgsqlcommand.a(string a_0, encoding a_1, arraylist a_2, boolean a_3) @ devart.data.postgresql.pgsqlcommand.internalexecute(commandbehavior behavior, idisposable stmt, int32 startrecord, int32 maxrecords) @ devart.common.dbcommandbase.internalexecute(commandbehavior behavior, idisposable stmt, int32 startrecord, int32 maxrecords, boolean nonquery) @ devart.common.dbcommandbase.executedbdatareader(commandbehavior behavior, boolean nonquery) @ devart.common.dbcommandbase.executedbdatareader(commandbehavior behavior) @ system.data.common.dbcommand.executereader(commandbehavior behavior) @ devart.data.postgresql.entity.y.a(commandbehavior a_0) @ devart.common.entity.i.b(commandbehavior a_0) @ devart.data.postgresql.entity.y.b(commandbehavior a_0) @ system.data.common.dbcommand.executereader(commandbehavior behavior) @ system.data.mapping.update.internal.dynamicupdatecommand.execute(updatetranslator translator, entityconnection connection, dictionary`2 identifiervalues, list`1 generatedvalues) @ system.data.mapping.update.internal.updatetranslator.update(ientitystatemanager statemanager, ientityadapter adapter) innerexception:
what doing wrong?
your code works in our environment: a) dotconnect postgresql v 6.7.287 b) sharpmap v1 rc3 c) postgis 2.0 d) ddl: create table monitoring_object ( id serial not null, geometry geometry, last_changed_by character varying );
please give us following information: 1) version of sharpmap. aware current release of dotconnect postgresql supports sharpmap 1.0 rc3 ( http://sharpmap.codeplex.com/releases/view/106717 ). 1.0 final version supported 2) version of postgis. should of 2.0 (or higher) version. can check executing "select postgis_version()" in database 3) ddl script of monitoring_object table 4) if possible send us small test project
the corresponding devart documentation available @ http://blogs.devart.com/dotconnect/enhanced-entity-framework-spatials-support-for-oracle-mysql-and-postgresql.html .
Comments
Post a Comment