UseNpgsql not available in IServiceCollection in .NET Core

I have a .NET Core project in Visual Studio 2017. I am trying to add a (Postgresql) database connection. Here is the code:

public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddDbContext<ConexionWebApi>(options => { options.UseNpgsql("ConnectionString", b => b.MigrationsAssembly("WebAPISample")); }); } 

But useNpgsql generates the following error:

'DbContextOptionsBuilder' does not contain a definition for 'UseNpgsql', and the extension method 'UseNpgsl' cannot be found that accepts the first argument of the type 'DbContextOptionsBuilder' (do you miss the using or refence directive?)

I installed the following NuGet packages:

 Microsoft.EntityFrameworkCore.Tools, Npgsql.EntityFrameworkCore.PostgreSQL, Npgsql.EntityFrameworkCore.PostgreSQL.Design. 

Should I install any other library?

+5
source share
1 answer

I had the same problem. I resolved it by adding

 using Microsoft.EntityFrameworkCore; 
0
source

Source: https://habr.com/ru/post/1269772/


All Articles