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?
source share