Npgsql:`AddEntityFrameworkNpgsqlTrigrams` 做什么?
Npgsql: What does `AddEntityFrameworkNpgsqlTrigrams` do?
由于 Ngpsql 文档没有 comperhensive page for fuzzy string matching, I went with what test cases 正在使用,因此出现以下错误:
Exception has occurred: CLR/System.AggregateException
An unhandled exception of type 'System.AggregateException' occurred in API.dll: 'Some services are not able to be constructed'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.InvalidOperationException : Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource' while attempting to activate 'Npgsql.EntityFrameworkCore. PostgreSQL.Query.ExpressionTranslators.Internal.NpgsqlTrigramsMethodCallTranslatorPlugin'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
通常我会问发生了什么,但我注意到如果我不使用 AddEntityFrameworkNpgsqlTrigrams,我能够编译和调用三元组函数(确切地说是 TrigramsSimilarity)导致我的表达被成功翻译。所以我的问题是:AddEntityFrameworkNpgsqlTrigrams 有什么用?我可以不提吗?
我应该注意,我使用的是 Npgsql.EntityFrameworkCore.PostgreSQL.Trigrams 版本 3.1.4。我们还没有迁移到 .NET 5.0
通常使用 Trigram 插件的方法是参考 OnModelConfiguring
中的 Npgsql.EntityFrameworkCore.PostgreSQL.Trigrams nuget package, and call UseTrigrams:
options.UseNpgsql(@"<connection string>", o => o.UseTrigrams())
This is documented here。应用程序很少需要直接调用 AddEntityFrameworkNpgsqlTrigrams。
由于 Ngpsql 文档没有 comperhensive page for fuzzy string matching, I went with what test cases 正在使用,因此出现以下错误:
Exception has occurred: CLR/System.AggregateException An unhandled exception of type 'System.AggregateException' occurred in API.dll: 'Some services are not able to be constructed' Inner exceptions found, see $exception in variables window for more details. Innermost exception System.InvalidOperationException : Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSource' while attempting to activate 'Npgsql.EntityFrameworkCore. PostgreSQL.Query.ExpressionTranslators.Internal.NpgsqlTrigramsMethodCallTranslatorPlugin'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
通常我会问发生了什么,但我注意到如果我不使用 AddEntityFrameworkNpgsqlTrigrams,我能够编译和调用三元组函数(确切地说是 TrigramsSimilarity)导致我的表达被成功翻译。所以我的问题是:AddEntityFrameworkNpgsqlTrigrams 有什么用?我可以不提吗?
我应该注意,我使用的是 Npgsql.EntityFrameworkCore.PostgreSQL.Trigrams 版本 3.1.4。我们还没有迁移到 .NET 5.0
通常使用 Trigram 插件的方法是参考 OnModelConfiguring
中的 Npgsql.EntityFrameworkCore.PostgreSQL.Trigrams nuget package, and call UseTrigrams:
options.UseNpgsql(@"<connection string>", o => o.UseTrigrams())
This is documented here。应用程序很少需要直接调用 AddEntityFrameworkNpgsqlTrigrams。