在使用Entity Framework6.4.4和.NET 6在数据库中存储DbGeography类型的数据时,我收到以下错误:
不存在从对象类型Microsoft.SqlServer.Types.SqlGeography到已知托管提供程序本机类型的映射.
使用最新版本的Microsoft.SqlServer.Types:160.1000.6.
堆栈跟踪:
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: 不存在从对象类型Microsoft.SqlServer.Types.SqlGeography到已知托管提供程序本机类型的映射.
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()
将数据保存到数据库时出错.(EF SaveChanges())