I am using PostgreSQL 12 with EF6. I am trying to add materialized view to my model but the view is not listed in the model wizard. I know to be able to add a view into a model, Entity Framework needs at least one column in database view to be not nullable. But I am not sure how to do it.
I have tried creating unique index and also rownumber with no success.
CREATE MATERIALIZED VIEW "Stock"
AS
SELECT coalesce(cast(ROW_NUMBER() OVER() as int), 0) as "Id",
"PartMaster"."PartID",
"OEMPart"."PartCatalogID",
"PartMaster"."PartCode",
"PartCatalog"."CustomPartCode",
"OEMPart"."OEMCode",
"PartMaster"."PartDesc",
"GoodsReceivedDetail"."Cost",
"GoodsReceivedDetail"."Markup",
"GoodsReceivedDetail"."SellingPrice",
coalesce("GoodsReceivedDetail"."Quantity", 0) as "InQuantity",
coalesce("InvoiceDetail"."Quantity", 0) as "OutQuantity",
coalesce("GoodsReceivedDetail"."Quantity", 0) - coalesce("InvoiceDetail"."Quantity", 0) as "StockQuantity"
FROM
"PartCatalog"
INNER JOIN
"PartMaster"
ON
(
"PartCatalog"."PartID" = "PartMaster"."PartID")
INNER JOIN
"OEMPart"
ON
(
"PartCatalog"."PartID" = "OEMPart"."PartID")
INNER JOIN
"GoodsReceivedDetail"
ON
(
"OEMPart"."PartCatalogID" = "GoodsReceivedDetail"."PartCatalogID")
LEFT OUTER JOIN
"InvoiceDetail"
ON
(
"GoodsReceivedDetail"."PartCatalogID" = "InvoiceDetail"."PartCatalogID")
INNER JOIN
"PartCategory"
ON
(
"PartMaster"."PartCategoryID" = "PartCategory"."PartCategoryID") ;
CREATE UNIQUE INDEX "Id"
ON "Stock" ("PartCatalogID");