0

I have a Postgres 12 database that currently only consists of one simple table:

CREATE TABLE public.messages
(
    sender text COLLATE pg_catalog."default",
    "timestamp" timestamp with time zone,
    message_id bigint,
    text text COLLATE pg_catalog."default",
    priority bigint,
    parameters text[] COLLATE pg_catalog."default"
)

No I want to use Npgsql to build a GUI with C# and Entity Framework. I installed the Nuget package:

Install-Package EntityFramework6.Npgsql

and it succeeded:

Successfully installed 'EntityFramework6.Npgsql 6.4.0' to TestClient

Next, I installed the Npgsql integration for VS 2019 (found here). When I try to add an ADO.NET Entity Data Model to my project by right-clicking it in the solution explorer, I can add a connection and the connection test ist successful (done in the Wizard). I can go on and select my table, but as soon as I press Finish, I get an error:

enter image description here

This is the console output:

Unable to generate the model because of the following exception: 'System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> Npgsql.PostgresException: 42703: Column c.consrc does not exist

What can I do?

Rob
  • 11,492
  • 14
  • 59
  • 94
  • Which .Net Framework are you using ? If it is .Net Core, you need Npgsql.EntityFrameworkCore.PostGreSQL – user3041160 Feb 17 '20 at 09:40
  • I'm using/targetting .NET Framework 4.6 (not .NET Core) with Windows Forms, so the package should be alright, I think. – Rob Feb 17 '20 at 09:44

1 Answers1

2

PG12 removed the pg_constraint.consrc, this is tracked by PG12 removed the pg_constraint.consrc. Downgrading to PG11 should work until a fix is released.

Shay Rojansky
  • 15,357
  • 2
  • 40
  • 69
  • 1
    Note: have just published EntityFramework6.Npgsql 6.4.1 with a fix for this, can you give that a try? – Shay Rojansky Feb 17 '20 at 15:41
  • It works now, thanks for the update! But the [next problem is already there ;-)](https://stackoverflow.com/questions/60277281/how-to-deal-with-a-text-array-field-type-in-npgsql) – Rob Feb 18 '20 at 09:14