gpt4 book ai didi

ef-core-2.0 - 为什么在我的 ASP.Net Core 2.2 api 中尝试实现 UseNetTopologySuite 时出现此错误?

转载 作者:行者123 更新时间:2023-12-04 02:36:45 27 4
gpt4 key购买 nike

我正在尝试在 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 中创建我的实体并将其注入(inject)应用程序的其余部分有关。

有想法该怎么解决这个吗?

最佳答案

您需要删除 NetTopologySuite 库
只需使用 Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite .

关于ef-core-2.0 - 为什么在我的 ASP.Net Core 2.2 api 中尝试实现 UseNetTopologySuite 时出现此错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57718842/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com