4,815 questions
In Postgresql view cannot be created without primary key.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How do I scaffold view in MVC CORE , as it is failing due to lack of primary key
I am trying to create api using
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-7.0&tabs=visual-studio
CREATE TABLE public.visit (
visitid int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START 1 CACHE 1 NO CYCLE),
notes varchar(200) NULL,
visitdate date NOT NULL,
patientid int4 NULL,
clinicianid int4 NULL,
imagedata bytea NULL,
CONSTRAINT pk__visit PRIMARY KEY (visitid)
);
-- public.visit foreign keys
ALTER TABLE public.visit ADD CONSTRAINT "fk_dbo.visit_dbo.clinician_clinicianid" FOREIGN KEY (clinicianid) REFERENCES public.clinician(clinicianid);
ALTER TABLE public.visit ADD CONSTRAINT "fk_dbo.visit_dbo.patient_patientid" FOREIGN KEY (patientid) REFERENCES public.patient(patientid);
CREATE OR REPLACE VIEW public.visitview
AS SELECT v.visitid,
v.notes,
v.patientid,
v.clinicianid,
c.lastname AS clinicanlastname,
p.lastname AS patientlastname
FROM visit v,
patient p,
clinician c
WHERE v.patientid = p.patientid AND v.patientid = c.clinicianid;
In Postgresql view cannot be created without primary key.