ef-core-2.0 - 为什么在我的 ASP.Net Core 2.2 api 中尝试实现 UseNetTopologySuite 时出现此错误?
问题描述
我正在尝试在 Sql Server 和 EF Core 中使用几何功能。
我已经安装了以下软件包
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="2.2.6" />
<PackageReference Include="NetTopologySuite" Version="2.0.0" />
在我的 Startup.cs 中,我有以下内容:
services.AddDbContextPool<CRFlowContext>(options =>
options.UseSqlServer("connection string", x => x.UseNetTopologySuite());
});
一切正常,但是当我尝试运行该应用程序时,出现以下错误:
Application startup exception: System.MissingMethodException: Method not found: 'GeoAPI.IGeometryServices NetTopologySuite.NtsGeometryServices.get_Instance()'.
at Microsoft.Extensions.DependencyInjection.SqlServerNetTopologySuiteServiceCollectionExtensions.AddEntityFrameworkSqlServerNetTopologySuite(IServiceCollection serviceCollection)
at Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerNetTopologySuiteOptionsExtension.ApplyServices(IServiceCollection services)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices(IDbContextOptions options, ServiceCollection services)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.<GetOrAdd>b__2(Int64 k)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
at Entities.CRFlowContext..ctor(DbContextOptions`1 options) in C:\Src\myproj\myproj.Entities\MyProjContext.cs:line 11
at lambda_method(Closure )
at Microsoft.EntityFrameworkCore.Internal.DbContextPool`1.Rent()
at Microsoft.EntityFrameworkCore.Internal.DbContextPool`1.Lease..ctor(DbContextPool`1 contextPool)
我怀疑这与在 Program.cs 中创建我的实体并将其注入应用程序的其余部分有关。
有想法该怎么解决这个吗?
解决方案
对于任何看到这个的人,事实证明您需要安装 NetTopologySuite.Core,而不是 NetTopologySuite。
一旦我安装了这个,它工作得很好。
推荐阅读
- jenkins - 在 Jenkins 中安装“JavaScript GUI Lib”插件失败
- mysql - Mysql 导入 - CSV 文件越来越大
- reactjs - 处理 useMutation 钩子中的错误的最佳方法是什么
- python - 使用python生产的内存中sqlite
- asp.net-mvc - ajax 其他参数是否为空?
- c# - 一页验证中的 Asp Net Core 2 模型
- java - 无法在 R 上将 kafka 流作为 spark 数据帧流读取/写入
- azure-devops - AzureDevOps - YML - 如何将部署作业输出变量与 VM 资源一起使用
- python-3.x - pyshark.LiveCapture 未捕获数据包
- sql - 使用 SQL 对观察进行分组并在同一组中指定