Error using npgsql
See original GitHub issueHi have the following error while using npgsql on mac, using sql server it is ok.
I’m using your repo as a base for my own.
attached is the error.
dotnet ef migrations add PostgresInitial
Build succeeded. 0 Warning(s) 0 Error(s)
Time Elapsed 00:00:29.44
Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ItsomaxDbContext (ReflectionActivator), Services = [Itsomax.Module.Core.Data.ItsomaxDbContext], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions1 (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions
1[[Itsomax.Module.Core.Data.ItsomaxDbContext, Itsomax.Module.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> Could not load file or assembly ‘Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’. The system cannot find the file specified.
(See inner exception for details.) (See inner exception for details.) (See inner exception for details.) —> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions1 (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions
1[[Itsomax.Module.Core.Data.ItsomaxDbContext, Itsomax.Module.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> Could not load file or assembly ‘Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’. The system cannot find the file specified.
(See inner exception for details.) (See inner exception for details.) —> Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions1 (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions
1[[Itsomax.Module.Core.Data.ItsomaxDbContext, Itsomax.Module.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> Could not load file or assembly ‘Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’. The system cannot find the file specified.
(See inner exception for details.) —> System.IO.FileNotFoundException: Could not load file or assembly ‘Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’. The system cannot find the file specified.
at Itsomax.Module.Core.Extensions.ServiceCollectionExtensions.<>c__DisplayClass3_0.<AddCustomizedDataStore>b__0(DbContextOptionsBuilder options)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass0_01.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b) at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action
2 optionsAction)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass5_01.<AddCoreServices>b__0(IServiceProvider p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable
1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable
1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable
1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__5
1.<AddCoreServices>b__5_1(IServiceProvider p)
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable
1 parameters)
— End of inner exception stack trace —
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func
1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable
1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func1 creator) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable
1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable
1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Itsomax.WebHost.MigrationItsomaxDbContextFactory.Create(String[] args) in /Users/mkowoll/Development/DotNetCore/ItsomaxProject/Apps/ItsomaxCms/Itsomax.WebHost/MigrationItsomaxDbContextFactory.cs:line 38 at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass10_0.<FindContextTypes>b__3() at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func
1 factory)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_01.<Execute>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ItsomaxDbContext (ReflectionActivator), Services = [Itsomax.Module.Core.Data.ItsomaxDbContext], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DbContextOptions
1 (DelegateActivator), Services = [Microsoft.EntityFrameworkCore.DbContextOptions`1[[Itsomax.Module.Core.Data.ItsomaxDbContext, Itsomax.Module.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope —> Could not load file or assembly ‘Npgsql.EntityFrameworkCore.PostgreSQL, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7’. The system cannot find the file specified.
(See inner exception for details.) (See inner exception for details.) (See inner exception for details.)
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Just tested my own project based on Thiennn project and EF is working again. Even did a ef migrations without any issues. thx @roji
@thiennn will commit later into my project if you want to check it put.
FYI Npgsql supports .NET Core 2.0/.NET Standard 2.0 both at the ADO.NET level and at the EF Core provider.