No mapping exists from object type Microsoft.SqlServer.Types.SqlGeography to a known managed provider native type.

Tom van Oost 0 Reputation points
2023-03-13T13:33:39.89+00:00

I'm receiving the following error when storing data with DbGeography type in the database, using Entity Framework 6.4.4 and .NET 6:

No mapping exists from object type Microsoft.SqlServer.Types.SqlGeography to a known managed provider native type.

Using the latest version of Microsoft.SqlServer.Types: 160.1000.6.

Stacktrace:

System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> System.Data.Entity.Core.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details.
 ---> System.ArgumentException: No mapping exists from object type Microsoft.SqlServer.Types.SqlGeography to a known managed provider native type.
   at System.Data.SqlClient.MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen, Boolean streamAllowed)
   at System.Data.SqlClient.MetaType.GetMetaTypeFromType(Type dataType)
   at System.Data.SqlClient.SqlParameter.GetMetaTypeOnly()
   at System.Data.SqlClient.SqlParameter.get_SqlDbType()
Developer technologies | .NET | Other
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.