I've been having this issue for over a week, and I know there are lots of questions about this, but I haven't seen one using Oracle. I'm using EF Database First, I need to create an entity from a Oracle View and because of the "You need to define a primary key" restriction, EF won't let me.
Messages I've gotten:
- Key part 'COLUMN_NAME' for type 'VIEW_NAME' is not valid. All parts of the key must be non-nullable.
- Warning Error 6002: The table/view 'VIEW_NAME' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
Work arounds I've tried:
Modify de .edmx, and add the primary key myself. RESULT: The framework will say "That column is nullable, we can't accept that"
Modify my view using the following syntax:
CREATE OR REPLACE FORCE VIEW SCHEMA.MY_VIEW (COLUMN, FIELD1, FIELD2, FIELD3) AS SELECT NVL(ROW_NUMBER() OVER(ORDER BY FIELD1), 0) AS COLUMN , FIELD1 , FIELD2 , FIELD3 WITH READ ONLY; ALTER VIEW SCHEMA.MY_VIEW ADD CONSTRAINT MY_VIEW_PK PRIMARY KEY (CODIGO_MONEDA) RELY DISABLE;
I've tried many version of the query above, adding NVL to the others field, creating a primary key. I just can't get it to work.