npgsql: EntityFramework 7 - The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception.

I’m currently trying EntityFramework7 rc1-1. I have no problem on Windows but I have this exception on Linux with coreclr when I try to add a migration.

System.TypeInitializationException: The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.Assembly.GetTypes()
   at Npgsql.TypeHandlerRegistry..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Entity.Storage.Internal.NpgsqlTypeMapper..ctor()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CreateInstanceCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Data.Entity.Internal.DbContextServices.CreateModel()
   at Microsoft.Data.Entity.Internal.LazyRef`1.get_Value()
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.TransientCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.TransientCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Data.Entity.Design.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
   at Microsoft.Data.Entity.Commands.Program.Executor.<>c__DisplayClass6_0.<AddMigration>b__0()
   at Microsoft.Data.Entity.Commands.Program.Executor.Execute(Action action)
The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 33 (9 by maintainers)

Most upvoted comments

@Banashek it seems like you forgot to add dependency

"EntityFramework7.Npgsql.Design" :"3.1.0-rc1-5" 

to your project.json file.

OS - kubuntu 15.10 My full project.json:

            {
            "version": "1.0.0-*",
            "userSecretsId": "aspnet5-server-a720a4dd-92fb-4c89-8989-dcf7a8ee248a",
            "compilationOptions": {
                "emitEntryPoint": true
            },
            "tooling": {
                "defaultNamespace": "server"
            },

            "dependencies": {
                "EntityFramework.Commands": "7.0.0-rc1-final",
                "EntityFramework.Core": "7.0.0-rc1-final",
                "EntityFramework.Relational": "7.0.0-rc1-final",
                "EntityFramework7.Npgsql": "3.1.0-rc1-3",
                "EntityFramework.Relational.Design" : "7.0.0-rc1-final",
                "EntityFramework7.Npgsql.Design" :"3.1.0-rc1-5",
                "System.Net.Security": "4.0.0-beta-23516",
                "System.Net.NetworkInformation": "4.1.0-beta-23516",
                "runtime.linux.System.Net.NetworkInformation": "4.1.0-beta-23516",
                "runtime.unix.System.Net.Security": "4.0.0-beta-23516",
                "Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
                "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
                "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
                "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
                "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
                "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
                "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
                "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
                "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
                "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
                "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
                "Microsoft.Dnx.Runtime":"1.0.0-rc1-final",
                "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
                "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
                "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
                "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
                "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
                "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
                "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
            },

            "commands": {
                "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://*:5004",
                "ef": "EntityFramework.Commands"
            },

            "frameworks": {
                "dnx451": { },
                "dnxcore50": { 


                }
            },

            "exclude": [
                "wwwroot",
                "node_modules",
                "bower_components"
            ],
            "publishExclude": [
                "**.user",
                "**.vspscc"
            ],
            "scripts": {
                "prepublish": [
                "npm install",
                "bower install",
                "gulp clean",
                "gulp min"
                ]
            }
            }