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 :
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.
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:
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.