Page 1 of 1

Error: "Spatial types and functions are not available for this provider..." while saving to DB

Posted: Wed 30 Aug 2017 14:07
by DanielTulp
I use the dotConnect for PostgreSQL version 7.7.819.0 to connect my Asp.NET Web API application running on IIS to a PostgreSQL 9.5 database running on Apache Tomcat on a separate virtual server (VPS).
When I try to add multiple records locally, while my the app on my machine is connected to the online database, everything works fine.
When I try to add multiple records online, I get the error from the title. The error occurs when the dispose method on my unit of work is triggered, so when the records are stored in the database.

The weird thing is, I am not saving any geo information, just plain ASP.NET datatypes

Full error:
Message: Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found. , Stacktrace: at System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly()\r\n at System.Data.Entity.SqlServer.SqlSpatialServices.GeometryFromText(String wellKnownText)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.InitializeSpatialTypeDefaultMap()\r\n at System.Lazy`1.CreateValue()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Lazy`1.get_Value()\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.GetPropagatorResultForPrimitiveType(PrimitiveType primitiveType, PropagatorResult& result)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.Visit(EdmMember node)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.CreateEntitySetPlaceholder(EntitySet entitySet)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.Visit(DbScanExpression node)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.Propagator.Visit(DbProjectExpression node)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.<ProduceDynamicCommands>d__a.MoveNext()\r\n at System.Linq.Enumerable.<ConcatIterator>d__71`1.MoveNext()\r\n at System.Data.Entity.Core.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator)\r\n at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.ProduceCommands()\r\n at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)\r\n at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)\r\n at System.Data.Entity.Internal.InternalContext.SaveChanges()\r\n at WE.GprVoorraad.Repositories.EF.EFUnitOfWork.Dispose() in C:\\***\\WE.GprVoorraad.Repositories.EF\\EFUnitOfWork.cs:line 33\r\n at WE.GprVoorraad.Api.Controllers.UploadController.<PostCsvFile>d__6.MoveNext() in C:\\***\\WE.GprVoorraad.Api\\Controllers\\UploadController.cs:line 168\\n"

Re: Error: "Spatial types and functions are not available for this provider..." while saving to DB

Posted: Thu 31 Aug 2017 10:13
by Shalex
DanielTulp wrote:Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.
Stacktrace:
at System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly()
at System.Data.Entity.SqlServer.SqlSpatialServices.GeometryFromText(String wellKnownText)
Please make sure that your project is NOT set up for using System.Data.SqlClient provider (there are its classes in your stack trace).

If this doesn't help, upload a small test project with the corresponding DDL/DML script to ftp://ftp.devart.com (credentials: anonymous / yourEmail).

Re: Error: "Spatial types and functions are not available for this provider..." while saving to DB

Posted: Thu 31 Aug 2017 10:41
by DanielTulp
fixed!

had to include

Code: Select all

 <dependentAssembly>
        <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
      </dependentAssembly>
in the web.config

I used this to determine what the version number used on my server

Code: Select all

AppDomain currentDomain = AppDomain.CurrentDomain; 
Assembly[] assems = currentDomain.GetAssemblies(); 
foreach (Assembly assembly in assems) { 
_logger.Info(assembly.GetName().FullName); 
}
_logger is a Nlog logger

Re: Error: "Spatial types and functions are not available for this provider..." while saving to DB

Posted: Mon 04 Sep 2017 08:27
by Shalex
Thank you for confirming the fix.