question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error using npgsql

See original GitHub issue

Hi 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.DbContextOptions1[[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.DbContextOptions1[[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.DbContextOptions1[[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, Action2 optionsAction) at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass5_01.<AddCoreServices>b__0(IServiceProvider p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 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, IEnumerable1 parameters) at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 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__51.<AddCoreServices>b__5_1(IServiceProvider p) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) — End of inner exception stack trace — at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 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, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 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, IEnumerable1 parameters) at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 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(Func1 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 = 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.)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MathiasKowollcommented, Jun 1, 2017

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.

1reaction
rojicommented, Jun 1, 2017

FYI Npgsql supports .NET Core 2.0/.NET Standard 2.0 both at the ADO.NET level and at the EF Core provider.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceptions, errors and notices
Most exceptions thrown by Npgsql are either of type NpgsqlException, or wrapped by one; this allows your application to catch NpgsqlException where appropriate, ......
Read more >
c# - Npgsql exception when connecting
It's a bug with the initial set-up upon establishing a connection. There are a few different commands that get carried out on every ......
Read more >
Exception while reading from stream · Issue #4532
Hello All - I'm getting a very similar error. We are using .net 6.0.7 Npgsql 6.0.5 AWS Arora Postgres 12.7 with RDS proxy....
Read more >
Sharpdata/npgsql error - PostgreSQL
Hello, I have a PostgreSQL database that contains a number of tables, that contain columns of types such as geometry(Point),ltree and so on....
Read more >
Documentation: 15: Appendix A. PostgreSQL Error Codes
All messages emitted by the PostgreSQL server are assigned five-character error codes that follow the SQL standard's conventions for “SQLSTATE” codes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found