EF Core 3.1 迁移不适合 npgsql 和 nodatime
EF Core 3.1 migrations not playing nice with npgsql and nodatime
有人知道是什么导致了这个异常吗?拥有 asp.net 核心 3.1 和基础架构库 .netstandard2.1。使用 nodatime 设置 npgsql。但是按照他们的说明进行了 运行 添加迁移 我遇到了这种麻烦,不知道为什么?
An error occurred while accessing the Microsoft.Extensions.Hosting
services. Continuing without the application service provider. Error:
Some services are not able to be constructed (Error while validating
the service descriptor 'ServiceType:
Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSourcePlugin
Lifetime: Singleton ImplementationType:
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlNodaTimeTypeMappingSourcePlugin':
Unable to resolve service for type
'Microsoft.EntityFrameworkCore.Storage.ISqlGenerationHelper' while
attempting to activate
'Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlNodaTimeTypeMappingSourcePlugin'.)
(Error while validating the service descriptor 'ServiceType:
Microsoft.EntityFrameworkCore.Query.IMethodCallTranslatorPlugin
Lifetime: Singleton ImplementationType:
Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMethodCallTranslatorPlugin':
Unable to resolve service for type
'Microsoft.EntityFrameworkCore.Query.ISqlExpressionFactory' while
attempting to activate
'Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMethodCallTranslatorPlugin'.)
(Error while validating the service descriptor 'ServiceType:
Microsoft.EntityFrameworkCore.Query.IMemberTranslatorPlugin Lifetime:
Singleton ImplementationType:
Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMemberTranslatorPlugin':
Unable to resolve service for type
'Microsoft.EntityFrameworkCore.Query.ISqlExpressionFactory' while
attempting to activate
'Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMemberTranslatorPlugin'.)
是我的错。忘记了 startup.cs 中的以下语句。它们可以在 ConfigureServices 方法中的任何地方设置
public void ConfigureServices(IServiceCollection services)
{
...
services.AddEntityFrameworkNpgsql();
services.AddEntityFrameworkNpgsqlNodaTime();
...
}
有人知道是什么导致了这个异常吗?拥有 asp.net 核心 3.1 和基础架构库 .netstandard2.1。使用 nodatime 设置 npgsql。但是按照他们的说明进行了 运行 添加迁移 我遇到了这种麻烦,不知道为什么?
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMappingSourcePlugin Lifetime: Singleton ImplementationType: Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlNodaTimeTypeMappingSourcePlugin': Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage.ISqlGenerationHelper' while attempting to activate 'Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlNodaTimeTypeMappingSourcePlugin'.) (Error while validating the service descriptor 'ServiceType: Microsoft.EntityFrameworkCore.Query.IMethodCallTranslatorPlugin Lifetime: Singleton ImplementationType: Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMethodCallTranslatorPlugin': Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Query.ISqlExpressionFactory' while attempting to activate 'Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMethodCallTranslatorPlugin'.) (Error while validating the service descriptor 'ServiceType: Microsoft.EntityFrameworkCore.Query.IMemberTranslatorPlugin Lifetime: Singleton ImplementationType: Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMemberTranslatorPlugin': Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Query.ISqlExpressionFactory' while attempting to activate 'Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NpgsqlNodaTimeMemberTranslatorPlugin'.)
是我的错。忘记了 startup.cs 中的以下语句。它们可以在 ConfigureServices 方法中的任何地方设置
public void ConfigureServices(IServiceCollection services)
{
...
services.AddEntityFrameworkNpgsql();
services.AddEntityFrameworkNpgsqlNodaTime();
...
}