2013-07-24 1 views
0

PostgreSQL 용 최신 dotConnect를 설치했습니다. Postgres DB에 레코드를 삽입하려고합니다. 오류가 발생하는 기하학 열이 있습니다. 여기EF5에서 dotConnect로 Spatial Geometry 삽입 PostgreSQL 용 6.30

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(); 
} 

오류 메시지입니다 :

System.Data.Entity.Infrastructure.DbUpdateException was unhandled 
    HResult=-2146233087 
    Message=An error occurred while updating the entries. See the inner exception for details. 
    Source=EntityFramework 
    StackTrace: 
     at System.Data.Entity.Internal.InternalContext.SaveChanges() 
     at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() 
     at System.Data.Entity.DbContext.SaveChanges() 
     at ConsoleApplicationGEOdata.Program.Main(String[] args) in c:\Users\Stefan\Documents\Visual Studio 2012\Projects\ConsoleApplicationGEOdata\ConsoleApplicationGEOdata\Program.cs:line 38 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: System.Data.UpdateException 
     HResult=-2146233087 
     Message=An error occurred while updating the entries. See the inner exception for details. 
     Source=System.Data.Entity 
     StackTrace: 
      at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) 
      at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) 
      at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) 
      at System.Data.Entity.Internal.InternalContext.SaveChanges() 
     InnerException: System.ArgumentException 
      HResult=-2147024809 
      Message=Cannot convert value 
      Source=Devart.Data.PostgreSql 
      StackTrace: 
       at Devart.Data.PostgreSql.af.a(Object A_0, Type A_1, Encoding A_2) 
       at Devart.Data.PostgreSql.af.a(String A_0, Encoding A_1, PgSqlType A_2, Object A_3, Int32 A_4, Boolean A_5) 
       at Devart.Data.PostgreSql.PgSqlCommand.a(String A_0, Encoding A_1, ArrayList A_2, Boolean A_3) 
       at Devart.Data.PostgreSql.PgSqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords) 
       at Devart.Common.DbCommandBase.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords, Boolean nonQuery) 
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery) 
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior) 
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) 
       at Devart.Data.PostgreSql.Entity.y.a(CommandBehavior A_0) 
       at Devart.Common.Entity.i.b(CommandBehavior A_0) 
       at Devart.Data.PostgreSql.Entity.y.b(CommandBehavior A_0) 
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) 
       at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues) 
       at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) 
      InnerException: 

내가 잘못하고있는 중이 야 무슨 일이 코드는?

+0

PostgreSQL 6.7을 의미하지 않으며 오타가 있음을 알려주십시오. 'SELECT version();'그리고 출력을 여러분의 질문에 붙여주세요. (OK, PostgreSQL 6.7 릴리스가 없었기 때문에 6.7을 의미 할 수는 없었습니다. 아마도 PostgreSQL의 경우 DotConnect 6.7을 의미할까요?) –

+0

예외의 가장 중요한 부분을 잘라낸 것처럼 보입니다. 그 예외 출력은 불완전합니다. –

+0

죄송합니다. PostgreSQL 용 DotConnect 6.7입니다. 그것을 바꿨습니다. 예외는 모두 거기에있다 : 나는 "클립 보드에 예외 세부 사항 복사"를 수행했다. 마지막 InnerException은 null입니다. – StefanHa

답변

1

코드는 우리의 환경에서 작동 : 가) dotConnect PostgreSQL의 V 6.7.287 B) SharpMap V1이 RC3 C) PostGIS와 2.0 D) DDL을 위해 : 이 표는 ( 아이디 일련 NULL NOT, 을 monitoring_object CREATE 기하학 기하학, last_changed_by 문자가 변함 );

give us 다음 정보를 입력하십시오. 1) SharpMap 버전. PostgreSQL 용 dotConnect의 현재 릴리스는 SharpMap 1.0 RC3 (http://sharpmap.codeplex.com/releases/view/106717)을 지원합니다. 1.0 최종 버전은 곧 지원 될 것입니다. 2) 귀하의 Postgis 버전. 버전은 2.0 이상이어야합니다. 당신은 실행하여 확인할 수 있습니다 가능 send us 작은 테스트 프로젝트

해당 Devart 문서는 http://blogs.devart.com/dotconnect/enhanced-entity-framework-spatials-support-for-oracle-mysql-and-postgresql.html에서 사용할 수있는 경우 데이터베이스 3) monitoring_object 테이블 4의 DDL 스크립트)에 "() postgis_version을 선택합니다."

관련 문제