Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF/Postgres SQL database-first approach possible?

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

like image 712
sstassin Avatar asked May 06 '13 08:05

sstassin


1 Answers

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.

like image 51
Mordy Avatar answered Nov 15 '22 11:11

Mordy