MVC CORE Scaffold view to create api postgressql view

Anonymous
2023-09-21T11:45:38.6933333+00:00
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;


Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-09-29T12:37:47.7666667+00:00

    In Postgresql view cannot be created without primary key.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.