EF/Postgres SQL database-first approach possible?

entity-framework postgresql

Question

After hours of searching, I am little bit disappointed. Can anybody confirm (or not) that using EF database-first approch (I mean, using the VS EDMX degigner) is possible with an existing Postgres SQL database?

Some requirements :

  • I want to use ngsql provider because it is free (but I am not sure it is working in database-first approach)
  • I don't want to use the Devart Connect provider because it is not free and it is for a personal project. I can consider the express version but I don't think it is working on design mode.

Cheers

1
3
5/6/2013 9:08:56 AM

Accepted Answer

Yes it is possible. A quick Google search found a walkthrough which did not suggest there were any special gotchas.

I will note I am quite sceptical of code first ORM frameworks as I think that they leave out key aspects of database design and thus encourage databases where no real planning for the future has occurred and so I think it is somewhat of a specialized tool, but the answer seems to be yes, it works.

-2
6/5/2013 2:14:06 PM

Popular Answer

This question appears on most google searches for EF Database First with Postgres and the accepted answer directs to a walk-through on CODE first not DATABASE first so I'll add a pointer to this answer which got me most of the way to solving it:

PostgreSQL data provider missing from wizard in Visual Studio 2015

Essentially there is a Visual Studio extension for postgres (simply search in the extensions and updates for Postgres) but I also had to modify the entity framework node in my app.config as it was added before I installed the extension to look like this:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />      
      <provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
    </providers>
  </entityFramework>

This added npgsql as a data provider and after I did this the data provider appears in the EF Database first wizard as an option.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow