Entity Framework: Creating entities from Oracle View

entity-framework entity-framework-6 oracle

Question

I know there are many inquiries about this since I've had this problem for more than a week, but I haven't come across any that use Oracle. I want to construct an entity from an Oracle View using EF Database First, but EF won't allow me since it says "You need to declare a primary key."

My recent messages include:

  1. Key part 'COLUMN_NAME' for type 'VIEW_NAME' is not valid. The key's component elements must all be non-nullable.
  2. The table/view 'VIEW NAME' does not have a primary key declared, according to Warning Error 6002. The definition was made as a read-only table/view, and the key has been inferred.

Solutions I've tried:

  1. I'll edit the.edmx file and add the main key. RESULT: The framework will say "That column is nullable, we can't accept that"

  2. Change my viewpoint using the following phrasing:

    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 attempted many different iterations of the aforementioned query, adding NVL to the others column and making a main key. It simply won't work for me.

1
0
9/20/2016 4:24:33 PM

Accepted Answer

ZZZ_tmp
2
10/18/2016 8:44:21 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow