Why can't I insert into this postgres table with dapper?

-1

I have created the following tables in postgres:

CREATE TABLE users(id varchar NOT NULL PRIMARY KEY);
CREATE TABLE aggregates(id uuid NOT NULL PRIMARY KEY, user_id varchar NOT NULL REFERENCES users(id))

Now, I am trying to insert a record into users using dapper:

use connection = new NpgsqlConnection(connectionString)
connection.Execute("insert into users (id) values (@id)", (Map ["id", id]))

where id is a string. When I run this, I get the following exception:

Npgsql.PostgresException (0x80004005): 42703: column "id" does not exist

followed by this message:

There is a column named "id" in table "users", but it cannot be referenced from this part of the query

I can insert a record using psql from the command line:

insert into users(id) values ('123');

What's the problem with my dapper code?

postgresql
f#
dapper
asked on Stack Overflow Oct 20, 2019 by Dan O'Leary • edited Oct 21, 2019 by Sergey Berezovskiy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0