Rudis
Rudis

Reputation: 1217

ASP vNext and PostgreSql

exists currently any way, how to communicate with PostgreSql database, when I want to use ASP.NET vNext? I'm looking for solution, which will work mainly on linux.

EF7 supports only MS SQL a SqlLite now and Npgsql isn't ported for ASP.NET vNext.

Thanks

Upvotes: 7

Views: 2470

Answers (3)

CrazyPyro
CrazyPyro

Reputation: 3607

I'm still testing this out (on dnx-coreclr-win-x64.1.0.0-rc2-16177 at the moment), but they have made a lot of progress since @bricelam answered. They now have some EF7 docs including some on CoreCLR support

Here's part of my project.json:

"dependencies": {
  "EntityFramework.Commands": "7.0.0-rc2-*",
  "EntityFramework.Core": "7.0.0-rc2-*",
  "EntityFramework.Relational": "7.0.0-rc2-*",
  "EntityFramework7.Npgsql": "3.1.0-rc1-2",
},
"frameworks": {
  "dnxcore50": {}
}

You will probably need to add https://www.myget.org/F/npgsql-unstable/api/v3/index.json to your NuGet feeds in order to pull that package. EDIT: I now specify an exact version of EntityFramework7.Npgsql": "3.1.0-rc1-2" and use only this feed in my NuGet.config: https://www.myget.org/F/aspnetrelease/api/v3/index.json

EDIT: This is all now available in https://api.nuget.org/v3/index.json

In Startup.cs:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddEntityFramework()
            .AddNpgsql()
                .AddDbContext<YourDbContext>(options => options.UseNpgsql("your connectionString"))
            ;
    }

Upvotes: 2

druss
druss

Reputation: 1880

Instead of EF7 you can use NHibernate together with Fluent NHibernate. Npgsql is also working well on ASP.NET 5 (vNext) on Linux. Here is a complete example of ASP.NET vNext application with NHibernate + PostgreSQL working on ubuntu server.

Upvotes: 3

bricelam
bricelam

Reputation: 30365

The Npgsql community is working on an EF7 provider. I'm sure the code is available somewhere if you want to start using it.

Upvotes: 0

Related Questions