Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception (class libraries) #217

Closed
qvsmith opened this issue Jul 28, 2017 · 2 comments

Comments

@qvsmith
Copy link

qvsmith commented Jul 28, 2017

Initially I submitted and issue on EntityFrameWorkCore dotnet/efcore#9274

Please see that issue for background info.
Repro project: https://github.com/qvsmith/migration-issue-repro

I was getting the exception mentioned in the title here and after some reading I gathered that I had to specify a .NET Core app in the project startup option of dotnet ef tool.
This seemed to work great at first and I could add my first migration but, as you can see from issue I logged on EntityFrameWorkCore project the other DbContexts could not be found.

Then I was informed that I should be able to use dotnet ef migrations add command from a .NET Standard class library without needing to specify a different startup project.
I then tried this with EFCore for SqlServer and it worked.
So I'm back at the exception mentioned here in the title.

I looked at issue #32 but, that seems Linux specific and I'm on Win 8.1 with VS 2017.

Any help will be appreciated!

Update

If I do the most basic setup with Identity and Identity Server 4 (see DataAccess proj in repro) in a:

  • new .NET Standard (1.4) class library (dotnet ef migrations add fails with error in title)
  • new .NET Core (1.1) class library (dotnet ef migrations add fails with error in title)
  • new .NET Core (1.1) MVC Web App with no auth (dotnet ef migrations add works!)

I have no idea what the MVC template is adding that makes Npgsql.TypeHandlerRegistry happy??

Update 2
So from dotnet/efcore#7557 I updated Microsoft.EntityFrameworkCore.Tools.DotNet package to version 1.0.1 and now I'm able to add migrations to .NET Core (1.1) class library.
Initially I added System.Diagnostics.DiagnosticSource manually and received error in title but, then I saw it was already added as v4.3.0 and I searched for that error and came across issue 7557 above.

However, updating Microsoft.EntityFrameworkCore.Tools.DotNet package to 1.0.1 in .NET Standard class library did not solve issue. Now it's probably just down to a missing package...

@qvsmith qvsmith changed the title The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception (.NET Standard class library) The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception (class libraries) Jul 31, 2017
@PawelGerr
Copy link

Thanks for the hint!
Updating the version of Microsoft.EntityFrameworkCore.Tools.DotNet to 1.0.1 didn't help until I changed the sdk in my *.csproj file from <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="Microsoft.NET.Sdk.Web">

@roji
Copy link
Member

roji commented Jun 10, 2018

Closing for age and since these issues have likely gone away since. If there's still a problem please post and we'll revisit.

@roji roji closed this as completed Jun 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants