I have .NET Core project in Visual Studio 2017. I am trying to add (Postgresql) database connection. Here is a 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 no extension method 'UseNpgsl' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly refence?)
I installed the followings NuGet packages:
Microsoft.EntityFrameworkCore.Tools,
Npgsql.EntityFrameworkCore.PostgreSQL,
Npgsql.EntityFrameworkCore.PostgreSQL.Design.
Should I install some other library?
I had the same issue. I resolved it by adding
using Microsoft.EntityFrameworkCore;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With