Reputation: 463
I have a two tables in postgresql that look a little bit like this.
CREATE TABLE sailor
id serial NOT NULL,
boat_id integer NOT NULL,
name character varying(256),
CONSTRAINT sailor_id PRIMARY KEY (id)
CONSTRAINT boat_id FOREIGN KEY (boat_id)
REFERENCES boat (id) MATCH SIMPLE
ON UPDTE CASCADE ON DELETE CASCADE
CREATE TABLE boat
id serial NOT NULL,
name character varying(256),
CONSTRAINT boat_id PRIMARY KEY (id)
when I generate model from database I get the error "The relationship "boat_id" has columns that are not part of the key of the table on the primary side of the relationship. The relationship was excluded". I am probably missing something obvious, but 'boat (id)' is a primary key. Why do I get this error?
Upvotes: 0
Views: 903
Reputation: 1128
I have this erro message when I was try to update the model from database. The problem was that I had a table with two primary key and I was doing the relationship only with one of this primary key.
Upvotes: 0
Reputation: 463
Ok, so I found that the most probable offender was that the database had a foreign key constraint which had the same name as a primary key constraint.
Upvotes: 1