指定的类型未在目标服务器EF核心上注册用于空间点批量插入

时间:2019-05-08 18:25:01

标签: c# asp.net-core-mvc entity-framework-core entity-framework-extensions

我正在使用.NET Core MVC,Entity Framework Core,Entity Framework Extensions。我正在尝试通过BulkInsertAsync方法在EF Core中插入批量地址点,但出现错误

  

指定类型未在目标服务器上注册

由于Entity Framework Core具有适用于空间数据类型的nettopology。 Entity Framework Extension的BulkInsert方法在Entity Framework 6中工作正常,但在Entity Framework Core中却不能。

任何帮助或建议将不胜感激。

var geometryFactory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);
var newBreadcrumbs = (from b in addressPoints
                      select new BreadCrumb
                                 {
                                     CarrierId = carrierID,
                                     Point = geometryFactory.CreatePoint(new Coordinate(b.Longitude, b.Latitude)),
                                     Speed = b.Speed.GetValueOrDefault() * (Decimal)2.237,
                                     Direction = b.Direction,
                                     CapturedFrom = b.CapturedFrom,
                                     CapturedAt = DateTime.UtcNow,
                                     Accuracy = (Decimal)b.Accuracy,
                                     IsDisconnect = b.IsDisconnect,
                                     CreatedOn = DateTime.UtcNow,
                                     IsActive = true,
                                     CreatedBy = 0,
                                     ModifiedBy = 0,
                                     ModifiedOn = null
                                 }).ToList();

// this line of code causes the error
await dbCOntext.BulkInsertAsync(newBreadcrumbs);

1 个答案:

答案 0 :(得分:0)

此问题已在项目GitHub:https://github.com/zzzprojects/EntityFramework-Extensions/issues/209

中报告。

从v2.2.7开始,EF扩展现在通过nettopologysuite包支持空间类型。