Ziad Diyaa
Ziad Diyaa

Reputation: 31

Unable to create DbContext due to GetDatabaseLock method missing in Npgsql EF Core 9.x

I'm working on an ASP.NET Core project using Entity Framework Core and Npgsql for PostgreSQL. I'm trying to create a DbContext to manage my database, but I'm encountering the following error when I try to add a migration or run the application:

Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'Method 'GetDatabaseLock' in type 'Npgsql.EntityFrameworkCore.PostgreSQL.Migrations.Internal.NpgsqlHistoryRepository' from assembly 'Npgsql.EntityFrameworkCore.PostgreSQL, Version=9.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.' was thrown while attempting to create an instance.

I've confirmed that all my Entity Framework Core and Npgsql packages are on version 9.x, but the issue persists. The following includes a list of what I have tried to fix the issue

Upvotes: 3

Views: 2654

Answers (2)

Sk Shahnawaz-ul Haque
Sk Shahnawaz-ul Haque

Reputation: 588

Upgrading to 9.0.2 for Npgsql.EntityFrameworkCore.PostgreSQL solved for me.

Upvotes: 1

Shay Rojansky
Shay Rojansky

Reputation: 16722

FYI I'm working on bringing the PostgreSQL provider up to date with the latest EF previews - you'll have to wait until that happens.

Upvotes: 1

Related Questions