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.

System.TypeLoadException when configuring DbContext

See original GitHub issue

Exception details

System.TypeLoadException
  HResult=0x80131522
  Message=Method 'PopulateDebugInfo' in type 'Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension' from assembly 'Npgsql.EntityFrameworkCore.PostgreSQL, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.
  Source=Npgsql.EntityFrameworkCore.PostgreSQL
  StackTrace:
   at Microsoft.EntityFrameworkCore.NpgsqlDbContextOptionsExtensions.UseNpgsql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 npgsqlOptionsAction)
   at ...OnConfiguring(DbContextOptionsBuilder optionsBuilder)
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.Set[TEntity]()
   (further StackTrace is omitted)

Environment

Microsoft.EntityFrameworkCore 3.0.0-preview.19074.3
Npgsql.EntityFrameworkCore.PostgreSQL 3.0.0-ci.1451

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
calexander3commented, Nov 10, 2020

@CumpsD There is a prelease package that solved that issue for me.

1reaction
koryphaeecommented, Nov 11, 2020

After the upgrade I couldn’t connect to my old database. Turns out the PostgreSQL option “standard_conforming_strings” has to be “on” or Npgsql refuses to connect. Since PostgreSQL 9.1 “on” is the default value but apparently in our internal database this was manually turned off.

The following statement solves the issue:

ALTER DATABASE <db> SET standard_conforming_strings TO 'on';
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - TypeLoadException with DbContext
This type of error usually indicates that different assemblies are somehow referencing different versions of EntityFramework.dll.
Read more >
Scaffold-DbContext - System.TypeLoadException: Method ...
I am trying to install entity framework 3.1.0 to .netstandard 2.0. ... System.TypeLoadException: Method 'Create' in type 'Microsoft.
Read more >
System.TypeLoadException - elmah.io
TypeLoadException happens when a type could not be loaded by the CLR. This can be caused by several different issues, but here's a...
Read more >
"Entity Framework Core" -> "Add Migration" does not work
System.TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer' from assembly 'Microsoft.
Read more >
Abp.EntityFramework does not work with Core 2.x #7550
Error occurs in Startup.cs at "//Configure Log4Net logging" on "AddFacility" method. System.TypeLoadException HResult=0x80131522 ...
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