2017-07-12 13 views
5

Mam projekt .NET Core w Visual Studio 2017. Próbuję dodać (Postgresql) połączenie z bazą danych. Oto kod:UseNpgsql nie jest dostępny w IServiceCollection w .NET Core

public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddMvc(); 

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

} 

Ale useNpgsql generuje następujący błąd:

'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?)

Zainstalowałem następne Nuget pakiety:

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

należy zainstalować jakąś inną bibliotekę?

+0

Może być, że brakuje 'using' oświadczenie, które pozwoliłyby na wykorzystanie metody wydłużania – Nkosi

+0

odwołać z użyciem Microsoft.EntityFrameworkCore i nadal ten sam błąd. –

Odpowiedz

0

Miałem ten sam problem. Postanowiłem go dodając

using Microsoft.EntityFrameworkCore; 
Powiązane problemy